5 . 在参数传递过程中,使用关键字( )来修饰参数,可以使之按值传递。 (A)By Val (B)ByRef (C)Value (D)Reference
6.执行“工程”菜单中的( )命令,可以添加一个标准模块。 (A)添加过程(B) 通用过程(C)添加窗体(D)添加模块
7.假定已定义了一个过程Sub Add(a As Single,b As Single),则正确的调用语句是( )。
(A) Add 12, 12 (B)Call Add 2*x, Sin(1.57) (C) Call Add x, y (D)Call Add (12,12,x)
8.在窗体模块的通用声明段中声明变量时,不能使用( )关键字。 (A) Dim (B) Public (C) Private (D) Static
9.使用Public Const语句声明一个全局的符号常量时,该语句应放在()。 (A) 过程中 (B) 窗体模块的通用声明段
(C) 标准模块的通用声明段(D) 窗体模块或标准模块的通用声明段
二.判断程序或程序段的执行结果
1.单击命令执行按钮时,下列程序代码的执行结果为() Public Sub Proc1(n As Integer, ByVal m As Integer) n=n Mod 10 m=m\\10 End Sub
Private Sub Command1_Click() Dim x As Integer , y As Integer x=12:y=34
Call Proc1 (x,y) Print x; y End Sub
(A)12 34 (B )2 34 (C) 2 3 (D) 12 3
2.单击一次命令按钮之后,下列程序代码的执行结果为( )。如果去掉Static SUM 语句,则单击一次命令按钮的执行结果为( )。 Private Sub Command1_Click() S =P(1)+ P(2 )+ P(3) + P(4) Print S; End Sub
Private Function P(N As Integer ) Static SUM For I=1 to N SUM =SUM +I Next I P=SUM
End Function
(A) 20 (B) 35 (C) 115 (D) 135
3.单击命令按钮时,下列程序代码的执行结果为( )。
Private Function FirProc(x As Integer ,y As Integer ,z As Integer ) FirProc =2*x+y+3*z
30
End Function
Private Function SecProc(x As Integer ,y As Integer ,z As Integer ) SecProc =FirProc(z,x,y)+x End Function
Private Sub Command1_Click()
Dim a As Integer ,b As Integer,c As Integer a=2:b=3:c=4
Print SecProc(c,b,a) End Sub
(A) 21 (B) 19 (C) 17 (D) 34
4. 单击窗体时,下列程序代码的执行结果为()。
Private Sub Invert(ByVal xStr As String , yStr As String ) Dim tempStr As String Dim i As Integer i=Len(xStr) Do While i >= 1
tempStr =tempStr +Mid (xStr ,i , 1) i=i-1 Loop
yStr =tempStr End Sub
Private Sub Form_Click()
Dim s1 As String , s2 As String s1=”abcdef” Invert s1, s2 Print s2 End Sub
(A) abcdef (B) afbecd (C) fedcba (D) defabc 5. 单击窗体时,下列程序代码的执行结果为()。
Private Sub Value(ByVal m As Integer , ByVal n As Integer) m=m*2:n=n-5 Print m;n End Sub
Private Sub Form_Click()
Dim x As Integer,y As Integer x=10:y=15
Call Value(x,y) Printe x;y End Sub
如果删去Value过程形参表中的ByVal关键字,那么单击窗体时,程序代码的执行结果为()。 (A)20 10 (B) 10 15 (C) 20 15 (D) 20 10 10 15 20 10 10 15 20 10 6.单击窗体时,下列程序代码的执行结果为() Private Sub Form_Click()
Dim x As Integer, y As Integer, z As Integer
31
x=1:y=2:z=3
Call Procl(x,x,z) Call Procl(x,y,y) End Sub
Private Sub Proc1 (x As Integer ,y As Integer ,z As Integer ) x=3*z y=2*z z=x+y
Print x; y; z End Sub
如果在Procl过程第二个形参y前加ByVal 关键字,那么单击窗体时,程序代码的执行结果为( )。
(A)6 6 12 (B) 9 6 15 (C) 9 6 15(D)9 10 10 6 10 10 6 10 10 6 4 10 9 10 15 7.单击命令按钮时,下列程序代码的执行结果为()。 Private Sub Command1_Click() Print MyFunc(24,18) End Sub
Public Function MyFunc(m As Integer ,n As Integer ) As Integer Do While m<>n
Do While m>n: m=m-n: Loop Do While m Myfunc= m End Function (A)2 (B)4 (C)6 (D)8 8. 单击一次命令按钮时,下列程序代码的执行结果为()。 Dim a As Integer , b As Integer , c As Integer Private Sub Command1_Click() a=2: b=4: c=6 Call Proc1 (a, b) Print “a=”; a; “b=”; b; “c=”; c Call Proc2 (a, b) Print “a=”; a; “b=”; b; “c=”; c End Sub Public Sub Proc1(x As Integer , y As Integer ) Dim c As Integer x=2*x: y=y+2:c=x+y End Sub Public Sub Proc2 (x As Integer , ByVal y As Integer) Dim c As Integer x=2*x: y=y+2:c=x+y End Sub (A)a=2 b=4 c=6 (B) a=4 b=6 c=10 a=4 b=6 c=10 a=8 b=8 c=16 32 (C) a=4 b=6 c=6 (D) a=4 b=6 c=14 a=8 b=6 c=6 a=8 b=8 c=6 9. 单击窗体时,下列程序代码的执行结果为()。 Private Sub Form_Click() Test 2 End Sub Private Sub Test(x As Integer ) x=x*2+1 If x <6 Then Call Test(x) End If x=x*2+1 Print x; End Sub (A) 23 47 (B) 5 11 (C) 10 22 (D) 23 23 10. 给出下列程序代码在单击命令按钮时的输出结果。 Private Sub Command1_Click() Dim x As Integer , y As Integer Dim n As Integer , z As Integer x=1:y=1 For n =1 To 3 z= FirstFunc(x,y) Print n, z Next n End Sub Private Function FirstFunc(x As Integer , y As Integer ) As Integer Dim n As Integer Do While n <=4 x=x+y n=n+1 Loop FirstFunc=x End Function 三、程序填空 1.以下Function 过程Odd用于判断一个数是否是奇数。当单击命令按钮时,随机产生一个二位数,调用Odd过程,判断该数是否是奇数。如果是奇数,则显示True,否则显示False. Private Sub Command1_Click() Dim x As Integer x= (1) Print x. Odd(x) End Sub Function Odd(ByVal n As Integer ) As Boolean If (2) Then Odd=False 33 Else Odd=True End If End Function 供选择的答案: (1).(A)Int(Rnd*90+10) (B)Int(Rnd*89+10) (C)Int(Rnd*100) (D)Int(Rnd*90+11) (2 ). (A) n Mod 2 <>0 (B) n Mod 3 =0 (C) n Mod 2 =0 (D) n / 2 =0 2.已知函数sum(k,n)=1k+2k+??nk. 下面的Function过程Sum计算给定参数时含函数的值。 Private Function Sum(k As Integer , n As Integer ) As Integer Dim i As Integer , s As Long For i =1 To n s=s+Power((1)) Next i Sum =s End Function Private Function Power(a As Integer , b As Integer ) As Long Dim i As Integer , t As Long t=0 For i =1 To b (2) Next i (3) End Function 供选择的答案: (1)(A) k, i(B)k, n(C)k, s(D)s, k (2)(A)t=t+b(B)t=t+a(C)t=t*b(D)t=t*a (3)(A)Power =Sum (B)Power =t(C)Sum =Power (D)Sum =t 3.设工程中有两个窗体Form1、 Form2,一个标准模块Module1,设在Form2的代码中定义了以下过程: Sub aaa(x,y,z) z=x^2+y^2 End Sub 在Module1中定义了以下过程: Sub bbb(x,y,z) z=x^3+y^3 End Sub 要在Form1中单击命令按钮Command1时,调用以上过程计算两个数的平方和与立方和,并分别将结果显示在文本框Text3和Text4中, 请在以下程序段中写出相应的调用语句。 Private Sub Command1_Click() a=Val(Text1.Text) b=Val(Text2.Text) Call (1)__________ Text3.Text=c1 34 百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库VB程序习题集(新版)(7)在线全文阅读。
相关推荐: