1、一、选择题(共20分,每小题1分)1.以下方法不能打开代码窗口的操作是9)A.双击窗体上的对象B.双击工程资源管理窗口中的窗体文件图标C.单击工程资源管理窗口中“查看代码”按钮D,执行“视图”菜单中的“代码窗口”命令2.以下四组标识符,命名正确的一组是(A)A.name Int test5 my_carB.bike year?_sina mo neyC.str hello Integer to p$D.Cap 6Yuan myname%buy3如果要让文本框可以输入或显示多行文本,需要将文本框的(B)属性值设置为True。A.Text B.MultiLine C.Scro llBars D.E
2、nabled4.要强制显示声明变量,可在窗体模块或标准模块的声明中加 入语句(B)A.Optio n Base 0 B.Optio n ExplicitC.Optio n Base 1 C.Optio n Co mpare5.表达式100+100&100的值是(b)A.300 B.200100 C.100100100 D.1002006.算术表达式(sin(x)+a)/(bc+de)的VB表达式是(0A.Sin(x)+a/bAc+deB.Sin(x)+a/bAc+d*eC.(Sin(x)+a)/(b A c+d*e)D.Sin(x)+a/(bAc+d*e)7.下列语句的输出结果是(d)Dim
3、sum As Integersum=12.56Print sumA.12.56 B.12 C.报错 D.138,下列表达式可以判断变量str为大写字母字符的是(d)A.AstrZ B.,A,strHZHC.HAH=str=HZn D.HAH=str And str=HZH9,下列程序执行后,X的值是(b)Dim X As IntegerX=2Select Case XCase 0 To 3X=X+1Case Is 3X=X+2Case 2X=X+3End SelectA.2 B.3 c.4 D.510,下列程序的执行结果为(C)Dim I As IntegerFo ri=10 To 20 St
4、ep 2l=l+3Next IPrint IA.21 B.23 C.25 D.2711,下列程序的执行结果是(A)Dim A As Integer,B As IntegerA=0B=3WhileA 0)Or(y Mo d 400=0)ElsePrint y&“年不是闰年End IfEnd Sub2.程序代码如下:Dim A As IntegerA=20If A 5 ThenPrint“A5”ElselfA 10 ThenPrint“A10”ElsePrint HA=H;AEnd If程序执行的结果为A53.以下程序用于计算1+1/2+1/3+,直到最后一项小于 0.00001,请将程序补充完全
5、。Dim n As Lo ng,s As Singlen=1s=0While 1/n=0.00001_s=s+1/nn=n+1Wend4.以下程序用于计算S=1+3+32+33+.+31。的值,请将程序补 充完全。Dim S As Lo ng,T As Integer,I As IntegerS=0T=1Fo r I=0 To 10T=3AIS=S+TNext I5.程序代码如下:Dim a(10)As IntegerDim i As IntegerFo r i=1 To 10a(i)=2*i Next iFo r i=1 To 10Print a(i);Next i程序执行的结果为2 4 6
6、 8 10 12 1418 206.以下程序用于对数组进行从小到大的排序,请将程序 补充完全。Dim a(10)As IntegerDim i As Integer,j As Integer,t As IntegerFo r i=1 To 9Fo rj=1 To 10-iIf a(j)a(j+1)Thent=a(j)a(j)=a(j+1)a(j+1)=tEnd IfNext jNext i7.以下程序用于计算10行10列的二维数组的元素之和,请 将程序补充完全。Dim a(10,10)As IntegerDim i As Integer,j As Integer,S As IntegerS=0
7、Fo r i=1 To 10Fo rj=1 To 10a(i,j)=i*jNext jNext iFo r i=1 To 10Fo rj=1 To 10S=S+a(i,j)_Next jNext i8.程序代码如下:Sub Fact(ByVal a As Integer,ByRef b As Integer)a=a+10 b=b+5End SubPrivate Sub Co mmand1_Click()Dim X As Integer,Y As Integer X=10Y=20Fact X,YPrint X;YEnd Sub单击Co mmandl后程序执行的结果为 10 25m9.以下程序用于
8、计算Zn!=1!+2!+.+m!,请将程序补 充元全。Functio n Fact(m As Integer)As Lo ngDim i As IntegerDim t As Lo ng,S As Lo ngS=0t=1Fo r i=1 To mt二 t*i_S=S+tNext iFact=SEnd Functio n10.程序代码如下:Dim i As Integer,j As Integer,k As Integer k=0Fo ri=0To 10Step3Ifi 8 Then Exit Fo rFo rj=1 To 3 k=k+1Next jNext iPrint Hk=H;k程序执行的
9、结果为k=9得分 三、编程题(共70分,每小题7分)Private Sub Co mmand1_Click()i程DiWig As11As 匕匕叭导加恺06版三bcJ11 5旧,书 Valflfe澈t.丽百米1-J.il Texts lPText3单小干S(可2=Ifext3End SubCommandl2,程序界而加忖所示,Textl川Text24分别输X f仆川岛.编与Commandl;IJ Clickiifi 山丫,PHvatenSubEo mmandl在Cl论k()DDhVsJjaiHgen-h-A:L 311曲bbhTextS:冷:鲁2.Text)j、*r*hComnandlTAxt
10、R Tpxt=End SubPrivate Sub Co mman用工的)件过和实现Dim xM Integer,y As Integer也由 Comandl小X干1丫翱诙洌1佗祗)-1.一显小在Text3小Ifx v IRJFhqgzo日蛇忏)=10 AndlSTheny*二声CjmmandlElseEry vr 3 既 tX+3 d If7ext2.1 ext=btr(y)End SubRriv_SEI InputboxiA畋Mim=Val(lnputBo x(输入 m 的值”)f_m M。%:3+2 And m Mo d5=3 仆ehPrint”满足条件”I“件 足“不InUn BIJT
11、 s p 日一End IfEnd SubPrivateDAI A M it居%n lid Inputbox 服S As LDim n As Integern=VaglnputRo xC:输入 n 的值”)is.片心,(.r+疗小+l;wci为|$rFo r x=j1 To ns=s+x*x*x*x+3*x*x*x+2*x*x+1Next xPrint S=;sEnd SubPrivate Sub Co mmand1_Click()Dim n As Integer6,O服喻躯则版时b Ash n怆g%c AS I帼曲Fo r n=100 To 999qb胃o oI _4fl!Ill 15 伽 1
12、MHmo/lfa+b+c=5 Then Print nEnd IfNext nEnd Sub小Privaeub 9渤照M版胧()防而c。皿曲后生成曲Dim a(100)As Integer工.:J Dim i AshfgbrJsA81ntegr;兀 U-m+1)+a(*)|物K痂般使陋&)加oizu(Time)讲句)FcOSro 100TWT3而与后知怎Tx&V激 W)3一 n8Uqn;训的解J f Int(Rnd*(n彳2 tLJ.,ynzL T J-b11nJrd71e 二 N s4 899 6oo833AoD5 4o3244983 55 D8QFcieiFlt To 100$=s+a(i
13、)Next iTexfetTt 批 St的)Com milEnd BubPrivate Sub Command1_Click()鬻黑露渊颦用。劈9%馋眦TAs晚野1 10*10For i=1 To 5I Mr.jM刷典个暗腿 9:的随机整数,以矩阵的历式显示在Textl(TextlEa(i,j)=lnt(Rnd*1O)b冲g中Next i并求最大It标注Text2中For i=1 To 5Forj=1 To 51:W(A)Textl.Text=TNext jTextl.Text=TexNext i max=a(1,1)For i=1 To 5For j=1 To 5If max a(i,j)m
14、ax=a(i,j)0 7 9 6 51.诧又t&JvBCrLf最大船1 8 0 9.61 3 0 2 92 5 4 3 0Fhen9iim 小 diEnd IfNext jNext iText2.Text=Str(max)End SubFunctio n Fact(x As Integer)As Lo ng:;,.二初msAsUo ng.已f+3i+l一 黑脚I仲 s=2*x*x+3*x+1ac=s 心End Fundtidh Puneiion Fact(x A$Integer)As Long.oisiiifliidlPrivate Sub Co mmand1_Click()Wick史凰娜塘削岫娴口期加澄小的 舞标I Dim s As Integerx=Val(Text1.Text)C 巾 I-XleALTo s=Fact(x)Text2.Text=Str(s)End Sub10.编写Sub过程,对包含10个整型元素的一维数组进行加 密,加密翅帆生n加附厂一 序,再将每面祥栅心9 10,加密后数1-Integer)加密前数组为1 2345678法式如下:t=a(i)a(i)=a(11-i)a(11-i)=tNext iFo r i=1 To 10a(i)=a(i)+10 Next iEnd Sub