江苏计算机等级二级vb模拟试题1 |
第二部分:vb部分 21.代数表达式 , A. E^(x+y)+|x+y|^ B. Exp(x+y)+Sqr(Abs(x+y))/2*3.14159+1 C. (Exp(x+y)+Sqr(Abs(x+y)))/(2*3.14159+1) D.( Exp(x+y)+Sqr(Abs(x+y)))/2*π+1 22. 下面表达式的值为真的是______。 A. Mid("Visual Basic",1,12)=Right("Programming Language Visual Basic",12) B. "ABCRG">"abcde" C. Int(134.69)>=Cint(134.69) D. 78.9/32.77<=97.5/43.97 And -45.4>-4.98 23. 以下有关对象属性的说法中正确的是______。 A. 对象所有的属性都罗列在属性窗口列表中 B. 不同对象不可能有同名属性 C. 不同对象的同名属性取值一定相同 D. 对象的某些属性既可以在实行窗口中设置,也可以通过程序代码设置或改变 24.在窗体模块的通用声明处用下面的语句声明变量、数组,正确语句有______个。 ① Public A(5) As Integer ② Public N As Integer ③ Public St As String*10 ④ Public b() As Integer A. 2 B. 25. 单选按纽(OptionButton)用于一组互斥的选项中。若一个应用程序包含多组互斥条件,可在不同的______中安排适当的单选按纽,即可实现。 A. 框架控件(Frame)或图象控件(Image) B. 组合框(ComboBox)或 图象控件(Image) C. 组合框(ComboBox)或图片框(PictureBox) D. 框架控件(Frame)或图片框(PictureBox) 26. 下面的语句或方法,错误的有______。(其中m和n都 为Integer型变量) ① Dim Array(m,n) As Integer ② n=32764+6 ③ Print A=A+B;A+B ④ ChDriver "C:" A. 1 B. 27. 执行下面的程序,单击窗体后在窗体上显示的结果是_____。 Private Sub Form_Click() Dim Str1 As String, Str2 As String,I As Integer Str1="ab" For I=Len(Str1) To 1 Step -1 item=LCase(Mid(entry,I,1))&I Str1=Str1&Chr(Asc(Mid(Str1,I,1))+I) Next I Print Str1 End Sub A. abce B. abcd C. abdb D. abfd 28. 下面说法不正确的是______。 A. VB允许将一个数字字符串赋值给一个数值型的变量 B. VB允许使用未经说明的变量,其类型都是Variant类型 C. Cls只清除运行时在窗体或图形框中显示的文本或图形 D. 事件过程既可建在窗体模块中,也可建在标准模块中 29. 下面能够正确打开文件的一组语句是______。 A. Open "data1" For Output As #5 , Open "data1" For Input As #5 B. Open "data1" For Output As #5 , Open "data1" For Input As #6 C. Open "data1" For Input As #5 , Open "data1" For Input As #6 D. Open "data1" For Input As #5 , Open "data1" For Random As #6 30. 应用程序窗体的名称属性为Frm1,窗体上有一个命令按纽,其名称属性为Cmd1,窗体和命令按纽的Click 事件过程名分别为______。 A. Form_Click() Command1_Click() B. Frm1_Click() Command1_Click() C. Form_Click() Cmd1_Click() D: 二、填空题(请把答案填写在答题纸的相应答题号内,每个答题只占一行) 1.运行下面的程序,当单击窗体时,窗体上第一行内容是______(1)_____,第三行内容是 ______(2)________ ,第四行内容是_________(3)____________。 Dim x As Integer, y As Integer Private Sub Form_Click() Dim A As Integer, B As Integer A = 5: B = 3 Call Sub1(A, B) Print A, B Print x, y End Sub Private Sub Sub1(ByVal M As Integer, N As Integer) Dim x As Integer, y As Integer x = M + N: y = M - N M = fun1(x, y) N = fun1(y, x) End Sub Private Function fun1(A As Integer, B As Integer) As Integer x = A + B: y = A - B Print x, y fun1 = x + y End Function 2. 执行下面的程序,第一行输出结果是___(4)___,第二行输出结果是___(5)___。 OPtion Explicit Private Sub Form_Click() Dim I As Integer,J As Integer J=10 For I=1 To J I=I+1 J=J-I Next I Print I Print J End Sub 3. 执行下面的程序,第一行输出结果是___(6)___,第三行输出结果是___(7)___。 Private Sub Form_Click() Dim A As Integer, I As Integer A=2 For I=1 To 9 Call Sub1(I,A) Print I,A Next I End Sub Private Sub Sub1(X As Integer,Y As Integer) Static N As Integer Dim I As Integer For I=3 To 1 Step -1 N=N+X X=X+1 NEXT I Y=Y+N End Sub 4. 执行下面程序后,A(1,3)的值是___(8)___,A(2,2)的值是___(9)___,A(3,1)的值是___(10)___。 Option Explicit Private Sub Form_Click() Dim A(3,3) As Integer, I As Integer Dim J As Integer, K As Inteher,N As Integer For K=1 To 5 If K<=3 Then For I=1 To K N=N+1 A(I,K-I+1)=N Next I Else For I=1 To 6-K N=N+1 A(K-3+I,4-I)=N Next I End If Next K For K=1 To 3 For I =1 To 3 Print A(K,I); Next I Print Next K End Sub 5. 执行下面的程序,第一行输出结果是___(11)___,第二行输出结果是___(12)___。 Option Explicit Private Sub Form_Click() Dim I As Integer,J As Integer I=1:j=2 Call Test(I,J) Print I,J Call Test(I,J) Print I,J End Sub Private Sub Test(M As Integer,N As Integer) Static Sta As Integer M=M+N N=N+M+Sta Sta=Sta+M End Sub 6. 下面程序的功能是统计当前盘当前文件夹中的顺序文件data.txt中共有多少个英文单词,约定连续出现的英文字母定义为一个单词。 Option Explicit Private Sub Form_Click() Dim Char As String, St As String,Tem As String Dim Idx As Integer,Js As Long,Flen As long Dim F As Boolean,W As String*1 ___(13)___ Flen=Lof(10) St=Input(Flen,#10) Js=1 Do While Js<=Flen Then W=Mid(St,Js,1) If ___(14)___Then Tem=Tem+W F=True Else If F=True Then Idx=Idx+1 ReDim Preserve Char(Idx) Char(Idx)=Tem Tem=___(15)___ F=False End If ___(16)___ Print "共有";Idx;"个单词" For Js=1 To Idx Print Char(Js) Next Js Close #10 End Sub 7. 下面程序的功能是当循环次数一定时,统计生成互不相同的1——100之间的随机整数的个数。 Option Explicit Option Base 1 Private Sub Form_Click() Dim Data() As Integer, I As Integer,Idx As Integer Dim N As Integer, Temp As Integer,Flg As Boolean N=InputBox("输入循环次数") ReDim Data(1) Idx=1 Data(1)=Int(100*Rnd(1))+1 For I=1 To N Temp=Int(100*Rnd(1))+1 ___(17)___ Call COmpare(Data,Temp,Flg) If Flg=True Then Idx=Idx+1 ___(18)___ Data(Idx)=Temp End If Next I Print "生成";Idx;"个不相同的整数" For I=1 To Idx Print Data(I) If I Mod 10=0 Then Print Next I End Sub Private Sub Compare(Array() As Integer,K As Integer,Logic As Boolean) Dim Ub As Integer, I As Integer ___(19)___ For I=1 To Ub If Array(I)=K Then ___(20)___ End If Next I Logic=True End Sub 8. 下面程序的功能是验证回文数猜想。任取一自然数,将其倒过来,并将这两个数相加,然后把这个和数倒过来,与原来的和数相加……重复这个过程有限次,必将得到一个回文数。 所谓回文数指左右数字完全对称的自然数,例如,121,12321,898,111均是回文数。根据猜想,假如取一自然数68——68+86=154——154+451=605——605+506=1111,经过三步运算就得到回文数1111。 Option Explicit Private Sub Form_Click() Dim S As Long,D As Long,Sum As Long Dim Flg As Boolean S=InputBox("输入一个正整数") Do D=Fun(S) Sum =S+D Print Sum;"=";S;"+";D Call Comp(Sum,Flg) S=___(21)___ Loop Until Flg Print Sum;"是回文数" End Sub Private Function Fun(N As Long)As Long Dim Char As String,J As Long Dim I As Integer,Slen As Integer Char=Ltrim(Str(N)) ___(22)___ J=1 For I=1 To Slen Fun=Fun+Val(Mid(Char,I,1))*J ___(23)___ Next I End Function Private Sub Comp(N As Long,F As Boolean) Dim Ch As String,S As Integer,I As Integer S=Len(Ltrim(Str(N))) F=False Ch=Ltrim(Str(N)) For I=1 To___(24)___ If Mid(Ch,I,1)<>Mid(CH,S+1-I,1)Then Exit Sub Next I ___(25)___ End Sub 9. 若一个等比数列的首项为2,公比为3,其第n项到第m 项之和为720。下面是求出符合上述要求的n 和m 的程序。 Private Sub Command1_Click() Dim Num() As Integer, Q As Integer, A As Integer Dim i As Integer, N As Integer, M As Integer Const k As Integer = 720 ReDim Num(1) A = 2: Q = 3 Num(1) = A ____________(26)____________ Do A = A * Q i = i + 1 ___________(27)______________ Num(i) = A Loop Until Num(i) >= 720 Call Sum1(Num, N, M, k) Label1 = "第" + Str(N) & "项~第" & Str(M) & " 项的和是720" End Sub Private Sub Sum1(Num() As Integer, N As Integer, M As Integer, ByVal k As Integer) Dim Ub As Integer, s As Integer, i As Integer, Idx As Integer _________(28)____________ For i = 1 To Ub ________(29)_________________ N = i ________(30)______________ Do Until s >= k s = s + Num(Idx) Idx = Idx + 1 If s = k Then M = Idx–1 Exit For End If Next i End Sub 答案:
21.C22.A23.D24.A25.D26.C27.C28.D29.C30.C 1.10 6 2.5 4 3.10 -6 4.11 5.-20 6.4 8 7.12 86 8.4 9.5 10.6 11.3 5 12.8 16 13.Open "data.txt" For Input As #10 14.w>="A" and w<="Z" or W>="a" and w<="z" 15."" 16.js=js+1 17.Flg=False 18.Redim Preserve Data(idx) 19.Ub=Ubound(arry) 20.Exit Sub 21.Sum 22.Slen=Len(char) 23.J=J*10 24.S 25.F=True 26.I=1 27.Redim Preserve Num(i) 28.Ub=Ubound(Num) 29.S=0 30.Idx=i |