资源描述:
《VB 编程题汇编》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、VB编程题汇编PrivateSubcommand1_Click()'''不得删除本行注释DimaAsInteger,bAsDouble,iAsInteger,nAsIntegern=Val(Text1.Text)a=0b=0Fori=1Tona=a+ib=b+aNextiText2.Text=bEndSubPrivateSubCommand1_Click()'''不得删除本行注释Dimi%,xh$,xm$OpenApp.Path&""&"Xhxm.txt"ForOutputAs#1Fori=1To3xh=InputBox("请输入学号")xm=InputBox("请输入姓名")Write
2、#1,xh,xmNextiClose#1EndSubPrivateSubCommand2_Click()'''不得删除本行注释DimsasstringOpenApp.Path&""&"Xhxm.txt"ForInputAs#2DoWhileNotEOF(2)LineInput#2,sText1.Text=Text1.Text&s&vbCrLfLoopClose#2EndSubPrivateSubCommand1_Click()DimnAsInteger,iAsInteger,sAsDoublen=Val(Text1.Text)s=0Fori=1Tons=s+i^2NextiText2.T
3、ext=sEndSubPrivateSubCommand1_Click()‘”读取文件”按钮代码'''不得删除本行注释DimstAsStringText1.Text=""OpenApp.Path&""&“jmwb.txt"ForInputAs#1WhileNotEOF(1)Input#1,stText1.Text=Text1.Text+st+vbCrLfWendClose#1EndSubPrivateSubCommand2_Click()DimsAsString,coAsString,cAsString,DimnAsInteger,iAsInteger,pAsIntegers=Trim(
4、Text1.Text)n=Len(s)co=""Fori=1Tonc=Mid(s,i,1)p=Asc(c)+5co=co+Chr(p)NextiText2.Text=coEndSubPrivateSubCommand1_Click()DimcharAsString*1char=Trim(Text1.Text)IfNotIsNumeric(char)ThenIf(Asc(char)>=65AndAsc(char)<=90)Or_(Asc(char)>=97AndAsc(char)<=120)ThenLabel1.Caption="输入的是字母"Else:Label1.Caption="输入的
5、是其它符号"EndIfElse:Label1.Caption="输入的是数字"EndIfEndSub课本有完整代码PrivateSubCommand1_Click()Text1.Text=UCase(Text1.Tag)EndSubPrivateSubCommand2_Click()Text1.Text=LCase(Text1.Tag)EndSubPrivateSubCommand3_Click()Text1.Text=Text1.TagEndSubPrivateSubText1_KeyUp(KeyCodeAsInteger,ShiftAsInteger)'对于文本框控件中输入的每次键盘按
6、键弹起事件做一次文本内容保存Text1.Tag=Text1.Text'用Text1.Tag属性作为保存textbox控件文本内容的临时存储区EndSubPrivateSubcommand1_Click()'''不得删除本行注释DimaAsInteger,bAsInteger,cAsIntegerDimmaxAsInteger,minAsIntegera=Val(Text1.Text)b=Val(Text2.Text)c=Val(Text3.Text)max=a+b+Abs(a-b)max=max/2min=a+b-Abs(a-b)min=min/2max=max+c+Abs(max-c)m
7、ax=max/2min=min+c-Abs(min-c)min=min/2Text4.Text=maxText5.Text=minEndSub课本有完整代码PrivateSubCommand1_Click()DimaAsIntegera=Val(Text1.Text)If(aMod4=0AndaMod100<>0)OraMod400=0ThenText2.Text="闰年"Else:Text2.Text="非闰年"End