信息技术学业水平测试VB套操作题复习及答案.

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

PrivateSubCommand1_Click()Dimh,m,s,ssAsIntegerss=Val(Text1.Text)h=ss\3600m=(ss-h*3600)\60s=(ss-h*3600)Mod60Label1.Caption=CStr(h)Label2.Caption=CStr(m)Label3.Caption=CStr(s)EndSubVB操作一PrivateSubCommand1_Click()DimxAsString,yAsStringDimiAsIntegerDimtemp1AsString,temp2AsStringx=Text1.Texty=Fori=1ToLen(Text1.Text)temp1=Mid(x,i,1)temp2=9-temp1y=y+temp2NextiText2.Text=yEndSubVB操作一PrivateSubCommand1_Click()DimiAsInteger,aAsInteger,bAsInteger,cAsIntegerFori=100To999a=i\100b=(i-a*100)\10c=iMod10Ifa^3+b^3+c^3=iThenPrintiNextiEndsubVB操作一PrivateSubCommand1_Click()Dims(9)AsSingleFori=0To9s(i)=Val(InputBox(请输入一个数))NextiFori=9To0Step-1Prints(i)NextiEndSubVB操作一PrivateSubCommand1_Click()Dima,b,c,maxAsIntegera=Val(Text1.Text)b=Val(Text2.Text)c=Val(Text3.Text)IfabThenmax=aElsemax=bIfcmaxThenmax=cLabel3.Caption=CStr(max)EndSubVB操作一VB操作二打不开PrivateSubCommand1_Click()DimsAsSingleDimqAsSingleDimaAsSingleDimbAsSingleDimcAsSinglea=Val(InputBox(请输入边长a的值:))b=Val(InputBox(请输入边长b的值:))c=Val(InputBox(请输入边长c的值:))q=(a+b+c)/2s=Sqr(q*(q-a)*(q-b)*(q-c))PrintsEndSubVB操作三PrivateSubCommand1_Click()DimyearAsIntegeryear=Val(InputBox(请输入年号:))If((yearMod4=0)And(yearMod1000))Or(yearMod400=0)ThenPrint是闰年ElsePrint不是闰年EndIfEndSubVB操作三PrivateSubCommand1_Click()DimaAsInteger,bAsIntegerDimbaiAsInteger,shiAsIntegerDimgAsIntegera=Val(Text1.Text)bai=a\100shi=(a-bai*100)\10g=aMod10b=g*100+shi*10+baiText2.Text=CStr(b)EndSubVB操作三PrivateSubCommand1_Click()DimxAsSingle,yAsSinglea=3:b=-5x=Val(InputBox(请输入x的值))Ifx0Theny=x+5*aElsey=x-2*bEndIfPrinty=;CStr(y)EndSubVB操作三PrivateSubCommand1_Click()Dima,b,c,pAsSinglea=Val(Text1.Text)b=Val(Text2.Text)c=Val(Text3.Text)p=b*b-4*a*cIfp=0ThenX1=(-b+Sqr(p))/(2*a)X2=(-b-Sqr(p))/(2*a)PrintX1=;X1PrintX2=;X2ElsePrint该方程无实数根EndIfEndSubVB操作三PrivateSubCommand1_Click()DimWuyuanAsIntegerDimYiyuanAsIntegerDimWujiaoAsIntegerForWuyuan=1To20ForYiyuan=1To100Wujiao=100-Wuyuan-YiyuanIfWuyuan*5+Yiyuan*1+Wujiao*0.5=100ThenPrintWuyuan=&Wuyuan&,Yiyuan=&Yiyuan&,Wujiao=&WujiaoEndIfNextYiyuanNextWuyuanEndSubVB操作四PrivateSubCommand1_Click()DimxAsSingleDimcostAsSinglex=Val(InputBox(请输入苹果公斤数:))Ifx=2Thencost=6.8*xElsecost=x*6.8*0.8EndIfPrintcostEndSubVB操作四PublicFunctionFib(nAsInteger)AsIntegerIf(n=1)Or(n=2)ThenFib=1ElseFib=Fib(n-1)+Fib(n-2)EndifEndFunctionPrivateSubCommand1_Click()DimSAsIntegerS=Fib(10)PrintS=&CStr(S)EndSubVB操作四PrivateSubCommand1_Click()Dima,b,cAsIntegerLeta=Val(Text1.Text)Letb=Val(Text2.Text)Letc=Val(Text3.Text)If(a+bc)And(a+cb)And(b+ca)ThenLetText4.Text=OKElseLetText4.Text=NOEndIfEndSubVB操作四PrivateSubCommand1_Click()Dimi,a,bAsIntegerFori=100To999a=i\100b=(i-a*100)\10c=iMod10Ifa*a*a+b*b*b+c*c*c=iThenPrintCStr(i)EndIfNextiEndSubVB操作五PrivateSubCommand1_Click()Dimh,x,yAsSingleLetx=Val(Text1.Text)Leth=Val(Text2.Text)Lety=x-(h/100)*0.5LetText3.Text=yEndSubVB操作五PrivateSubCommand1_Click()DimaAsIntegerDimbAsIntegerDimtAsIntegera=Val(Text1.Text)b=Val(Text2.Text)t=aa=bb=tText1.Text=aText2.Text=bEndSubVB操作五PrivateSubCommand1_Click()Dimn,iAsLongDimyesAsBooleanLetn=Val(Text1.Text)Letyes=TrueFori=2Ton\2IfnModi=0ThenLetyes=FalseEndIfNextiIfyesThenLetText2.Text=yesElseLetText2.Text=noEndIfEndSubVB操作五PrivateSubCommand1_Click()Constpi=3.14Dimr,sAsSingler=Val(T1.Text)s=pi*r*rT2.Text=sEndSubVB操作五PrivateSubCommand1_Click()Form1.Caption=Text1.TextEndSubVB操作六PrivateSubCommand1_Click()DimaAsIntegera=Val(Text1.Text)IfaMod2=0ThenLabel1.Caption=偶数ElseLabel1.Caption=奇数EndIfEndSubVB操作六PrivateSubForm_Click()DimiAsIntegerDimjAsIntegerPrintFori=-3To3PrintTab(3);Forj=1To3-Abs(i)Print*;NextPrint*NextEndSubVB操作六PrivateSubCommand1_Click()DimsAsSingle's计算存款DimyAsInteger'y计算年份DimrAsSingle'r是年利率s=1000y=0r=Val(InputBox(输入年利率,数据输入框))DoWhiles=2000y=y+1s=s*(1+r)LoopPrinty;年以后,存款可以达到2000元EndSubVB操作六PrivateSubCommand1_Click()DimtzAsInteger'tz是桃子数DimtsAsInteger'ts是天数tz=1Forts=1To9tz=(tz+1)*2NexttsPrint最初共有桃子&tzEndSub倒推:第10天:1个第9天:4个第8天:10个第7天:22个。。第1天:?设今天X个,剩下为Y个(明天)那么Y=X-(1/2*X+1)=1/2*X-1则X=(Y+1)*2VB操作六PrivateSubForm_Load()Timer1.Interval=1000Label1.Caption=EndSubPrivateSubTimer1_timer()Label1.Caption=TimeEndSubVB操作七PrivateSubCommand1_Click()DimxAsIntegerDimsAsIntegerDimiAsIntegerFori=1To10x=Val(InputBox(NO.&i))s=s+xPrintCStr(x)NextiPrinttotal:&sEndSubVB操作七PrivateSubCommand1_Click()DimwAsInteger'w是行李重量DimpjAsInteger'pj是机票价格DimfyAsSinglew=Val(Text1.Text)pj=Val(Text2.Text)Ifw=20Thenfy=0Elsefy=(w-20)*pj*0.015EndIfText3.Text=fyEndSubVB操作七PrivateSubCommand1_Click()DimxAsSinglex=Val(InputBox(请输入x的值!))Ifx50Theny=0.8*xElseIfx=100Theny=0.7*xElsePrint输入的数据出界!EndIfEndIfPrintx,yEndSubVB操作七Dima(100)AsIntegerPrivateSubCommand1_Click()DimtotalAsIntegertotal=0Fori=1To100Ifa(i)Mod2=0Thentotal=total+1EndIfNextiPrintCStr(total)EndSubPrivateSubForm_Load()RandomizeFori=1To100a(i)=Int(Rnd*1000)NextiEndSubVB操作七VB操作八PrivateSubCommand1_Click()DimvAsSinglev=Val(InputBox(请输入飞船速度的值))SelectCasevCaseIs16.67Label1.Caption=飞船挣脱太阳引力飞出太阳系caseis=11.19Label1.Caption=飞船离开地球的控制,围绕太阳转caseis=7.91Label1.Caption=飞船绕地球似做匀速圆周运动CaseElseLabel1.Caption=输入数据错误!EndselectEndSubPrivateSubCommand1_Click()Dima(10)AsIn

1 / 62
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功