欢迎来到天天文库
浏览记录
ID:30083223
大小:8.21 MB
页数:18页
时间:2018-12-26
《vb上机考试综合应用题选讲》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、VB上机考试综合应用题选讲一、素数判断与计算、输出题,并把计算与存盘部分补充完整!PrivateFunctionisprime(aAsInteger)AsBooleanDimflagAsBooleanflag=Trueb%=2DoWhileb%<=Int(a/2)AndflagIfInt(a/b%)=a/b%Thenflag=FalseElseb%=b%+1EndIfLoopisprime=flagEndFunction+++++++以下黑体字部分是程序中没有的,需要自己被充+++++++PrivateSubC1_Click()DimiAsIntegeri=18000Doi=i-1LoopUn
2、tilisprime(i)Text1.Text=iEndSubPrivateSubC2_Click()Open"out5.txt"ForOutputAs#1Print#1,Text1.TextClose#1EndSub二、判断口令题,关键是一些循环语句及选择结构的综合应用:PrivateSubC1_Click()IfText1.Text="123456"ThenText1.Text="口令正确"Text1.PasswordChar=""ElseText2.Text=Text2.Text-1IfText2.Text>0ThenMsgBox"第"&(3-Text2.Text)&"次口令错误,请重新
3、输入"ElseMsgBox"3次输入错误,请退出"Text1.Enabled=FalseEndIfEndIfEndSub三、图片转换题:PrivateSubTimer1_Timer()a=a+1Ifa>6Thena=1EndIfSelectCaseaCase1P1.Picture=LoadPicture("黄灯.ico")Case2,3P1.Picture=LoadPicture("红灯.ico")Case4,5,6P1.Picture=LoadPicture("绿灯.ico")IfbThenTimer2.Enabled=bEndSelectEndSubPrivateSubTimer2_Tim
4、er()If(a<4)And(P2.Left>P1.LeftAndP2.Left5、20Input#1,Arr1(i)NextiClose#1EndSubSubReadData2()OpenApp.Path&""&"datain2.txt"ForInputAs#1Fori=1To20Input#1,Arr2(i)NextiClose#1EndSubSubWriteData(FilenameAsString,NumAsInteger)OpenApp.Path&""&FilenameForOutputAs#1Print#1,NumClose#1EndSubPrivateSubC1_Click()ReadData1ReadData2EndSubPrivateSubC2_Clic6、k()Dimarr3(20)AsIntegerSum=0Fori=1To20arr3(i)=Arr1(i)Arr2(i)Sum=Sum+arr3(i)NextPrintSumEndSubPrivateSubC3_Click()WriteData"dataout.txt",SumEndSub五、倒计数器PrivateSubC1_Click(IndexAsInteger)SelectCaseIndexCase1Timer1.Enabled=FalseCase0Timer1.Enabled=TrueEndSelectEndSubPrivateSubForm_Load()EndSubPrivateS7、ubTimer1_Timer()Text1.Text=Text1.Text+1EndSub六、文本框的使用PrivateSubC1_Click()OpenApp.Path&"out7.txt"ForOutputAs#2Print#2,Text1.TextClose#2EndSubPrivateSubForm_Load()OpenApp.Path&"in7.txt"ForInputAs#1DoW
5、20Input#1,Arr1(i)NextiClose#1EndSubSubReadData2()OpenApp.Path&""&"datain2.txt"ForInputAs#1Fori=1To20Input#1,Arr2(i)NextiClose#1EndSubSubWriteData(FilenameAsString,NumAsInteger)OpenApp.Path&""&FilenameForOutputAs#1Print#1,NumClose#1EndSubPrivateSubC1_Click()ReadData1ReadData2EndSubPrivateSubC2_Clic
6、k()Dimarr3(20)AsIntegerSum=0Fori=1To20arr3(i)=Arr1(i)Arr2(i)Sum=Sum+arr3(i)NextPrintSumEndSubPrivateSubC3_Click()WriteData"dataout.txt",SumEndSub五、倒计数器PrivateSubC1_Click(IndexAsInteger)SelectCaseIndexCase1Timer1.Enabled=FalseCase0Timer1.Enabled=TrueEndSelectEndSubPrivateSubForm_Load()EndSubPrivateS
7、ubTimer1_Timer()Text1.Text=Text1.Text+1EndSub六、文本框的使用PrivateSubC1_Click()OpenApp.Path&"out7.txt"ForOutputAs#2Print#2,Text1.TextClose#2EndSubPrivateSubForm_Load()OpenApp.Path&"in7.txt"ForInputAs#1DoW
此文档下载收益归作者所有