VB-读程序题(2)

2019-08-26 17:57

16、单击命令按钮时,下列程序的执行结果为 Private Sub Command1_Click() Dim x As Integer, y As Integer x=12: y=32

Call PCS(x, y) Print x; y End Sub

Public Sub PCS(ByVal n As Integer, ByVal m As Integer) n=n Mod 10 m=m Mod 10 End Sub

A) 12 32 B) 2 32

C) 2 3 D) 12 3

17、单击一次命令按钮后,下列程序的执行结果是 Private Sub Command1_Click() s=P(1) + P(2) + P(3) + P(4) Print s End Sub

Public Function P(N As Integer) Static Sum For i=1 To N Sum=Sum + i Next i P=Sum End Function

A) 15 B) 25

C) 35 D) 45

18、下列程序的执行结果为

Private Sub Command1_Click() Dim s1 As String, s2 As String s1=\

Call Invert(s1, s2) Print s2 End Sub

Private Sub Invert(ByVal xstr As String, ystr As String) Dim tempstr As String i=Len(xstr) Do While i >=1

tempstr=tempstr + Mid(xstr, i, 1) i=i - 1

Loop

ystr=tempstr End Sub

A) fedcba B) abcdef

C) afbecd D) defabc 19、 在窗体上画一个名称为Commandl的命令按钮,再画两个名称分别为Labell、Label2 的标签,然后编写如下程序代码:

Private x As Integer

Private Sub Commandl_Click() x=5:y=3 Call proc(x,y)

LabeL1.Caption=x LabeL2.Caption=y End Sub

Private Sub proc(ByVal a As Integer,ByVal b As Integer) x=a* a y=b十b End Sub

程序运行后,单击命令按钮,则两个标签中显示的内容分别是(A)25 3 B)25 9 C)5 3 D)5 9 20 、在窗体上画一个命令按钮,然后编写如下事件过程: Private Sub Command1_Click() x=0

Do Until x=-1

a=InputBox(\请输入第一个数字a的值\ a=Val(A)

b=InputBox(\请输入第二个数字b的值\ b=Val(b)

x=InputBox(\请输入第三个数字x的值\ x=Val(x) a=a + b + x Loop Print a End Sub

21、下列程序段的执行结果为 I=4 x=5 Do

I=I + 1 x=x + 2

Loop Until I>=7 Print \

。 )Print \

A) I=4 x=5 B) I=7 x=15

C) I=6 x=8 D) I=7 x=11

22、下列程序段的执行结果为 a=1 b=5 Do

a=a + b b=b + 1

Loop While a < 10 Print a; b

A) 1 5 B) 12 7

C) a b D) 10 25

23、下列程序段的执行结果为 a=75

If a > 60 Then I=1 If a > 70 Then I=2 If a > 80 Then I=3 If a < 90 Then I=4 Print \

A) I=1 B) I=2

C) I=3 D) I=4

24、有如下事件过程:

Private Sub Command1_Click() b=10

Do Until b=-1

a=InputBox(\请输入a的值\ a=Val(A)

b=InputBox(\请输入b的值\ b=Val(b) a=a * b Loop Print a End Sub

程序运行后,依次输入数值30,20,10,-1,输出结果为 A) 6000 B) -10

C) 200

D) -6000

25、下面程序段执行结果为 x=Int(Rnd() + 3) Select Case x Case 5

Print \ Case 4

Print \ Case 3

Print \ Case Else

Print \End Select

A) excellent B) good

C) pass D) fail

26、定义过程的格式中,Static关键字的作用是指定过程中的局部变量在内存中的存储方式。若使用了Static关键字,则

A) 每次调用此过程,该过程中的局部变量都会被重新初始化

B) 在本过程中使用到的,在其他过程中定义的变量也为Statci型

C) 每次调用此过程时,该过程中的局部变量的值保持在上一次调用后的值 D) 定义了该过程中定义的局部变量为\自动\变量 27、单击命令按钮时,下列程序的执行结果为 Private Sub Command1_Click() Dim x As Integer, y As Integer x=50: y=78

Call PPP(x, y) Print x; y End Sub

Public Sub PPP(ByVal n As Integer, ByVal m As Integer) n=n \ 10 m=m \ 10 End Sub

A) 0 8 B) 50 78

C) 4 50 D) 78 50

28、单击按钮时,以下程序运行后的输出结果是

Private Sub proc1(x As Integer, y As Integer, z As Integer) x=3 * z y=2 * z z=x + y End Sub

Private Sub Command1_Click()

Dim x As Integer, y As Integer, z As Integer x=1: y=2: z=3

Call proc1(x, x, z) Print x; x; z

Call proc1(x, y, y) Print x; y; y End Sub

A) 6 6 12 6 10 10

B) 9 5 10 5 10 10

C) 9 6 12 9 10 15

D) 9 10 10 5 4 10

29、单击命令按钮时,下列程序的运行结果为 Private Sub Command1_Click() Print MyFund(20, 18) End Sub

Public Function MyFund(m As Integer, n As Integer) As Integer Do While m <> n

Do While m > n: m=m - n: Loop Do While m < n: n=n - m: Loop Loop MyFund=m End Function

A) 0 B) 2

C) 4 D) 6

30、在窗体上画一个命令按钮,然后编写如下程序 Private Sub Command1_Click() Dim a As Integer, b As Integer a=1 b=2

Print N(a, b) End Sub

Function N(x As Integer, y As Integer) As Integer N=IIf(x > y, x, y) End Function

程序运行后,单击命令按钮,输出结果为 A) 1 B) 2


VB-读程序题(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:与土有关的典型工程案例 - 图文

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: