VB试题库(8)

2020-02-20 13:55

End Function

运行时从键盘为变量x输入数据5,输出的结果是 (90) 。 38.下列程序运行后输出结果是 (91) 。 Private Sub Form_Click()

Dim k As Integer, t As Integer, s As Integer k = 1

For i = 5 To 1 Step -1 t = t * 10 + k s = s + t Next i Print s End Sub

39.下面的事件过程执行结束后,A(2)是 (92) ,A(3)是 (93) ,A(5)是 (94)

Option Explicit Option Base 1

Private Sub Command1_Click() Dim a(5) As Integer

Dim i As Integer, j As Integer, k As Integer For i = 1 To 5 a(i) = 1 Next i i = 2

Do While i <= 5 If a(i) = 1 Then j = i + i

For k = j To 5 Step i a(k) = 0 Next k End If i = i + 1 Loop

For k = 2 To 5

If a(k) = 1 Then a(k) = k Next k End Sub 40.下列程序

Private Sub Form_Click() a = 0

For j = 1 To 20 Step 2 a = a + j \\ 5 Next j Print a End Sub

运行后,输出的结果是 (95) 。 41.下列程序

Private Sub Form_Click()

a=10

For j=1 To 4

x=Val(InputBox(\请输入一个数\If x Mod 3=0 Then

b=b+x:a=x

Else

b=b+a

End If Next j Print b End Sub

运行时输入30,55,42,37,输出的结果是 (96) 。

42.执行下面程序,单击命令按钮Command1后,窗体上显示的第一行内容是 (97) ,第二行内容是 (98) ,最后一行内容是 (99) 。

Private Sub Command1_Click() Dim A As Integer, K As Integer A = 1

K = Fun((A), A) + Fun(A, (A)) Print "K="; K End Sub

Private Function Fun(X As Integer, Y As Integer) As Integer Dim K As Integer K = K + X X = X + Y Y = Y + K Fun = X + Y Print Fun; X; Y End Function

43.下面程序执行后,输出的第一行是 (100) ,第二行是 (101) ,第三行是 (102) 。

Option Explicit Private Sub proc()

Static s As Integer, k As Integer Dim i As Integer

For i = 1 To 10 Step 2 s = s + i Next i k = k + 1 Print k; s End Sub

Private Sub Form_Click() Dim i As Integer For i = 1 To 3 Call proc Next i

End Sub

44.执行下面的程序,在窗体上显示的输出结果的第一行是 (103) 。第二行是 (104) 。

Option Explicit

Private Sub Form_Click() Dim A As Integer a=3

Call Sub1(a)

End Sub

Private Sub Sub1(x As Integer) x=x*2+1

If x<10 then Call Sub1(x) End If x=x*2+1 Print x

End Sub 45.执行下面程序,从键盘输入3,程序运行结束后,a(1, 1)的值是 (105) ,a(2, 2) 的值是 (106) ;a(3, 3)的值是 (107) 。 Private Sub Form_Click()

Dim i As Integer, j As Integer, k As Integer Dim a() As Integer, n As Integer n = InputBox(\输入n\ ReDim a(n, n) For i = 1 To n For j = 1 To n k = k + 1

a(i, j) = k + 10 Next j Next i

Call Sub1(a, n) End Sub

Private Sub Sub1(a() As Integer, n As Integer) Dim i As Integer, j As Integer Dim t As Integer j = 1

For i = 1 To n t = a(i, j)

a(i, j) = a(i, 3) a(i, 3) = t Next i End Sub

46.下列程序第一次调用子程序后K= (108) , 第二次调用子程序后K= (109) Private Sub Command1_Click() Dim K As Integer

K=5

Call Prog(K)

Print \第一次调用:K=\ K=3

Call Prog(K)

Print \第二次调用:K=\

End Sub

Private Sub Prog(n As Integer) Static m As Integer m = n + m n = m + n

End Sub

47.下列程序段运行后,单击命令按钮时输出的第一行是 (110) ,第三行是 (111) 。

Private Sub Command1_Click()

Dim x As Integer, y As Integer, m As Integer y = 2

For x = 1 To 8 Step y m = x + y

Call sub1(m, x) Print m;x Next x End Sub

Private Sub sub1(ByVal a As Integer, b As Integer) a = a + b b = b + 1 End Sub

48.执行下列程序,当单击命令按钮时,窗体上输出的第一行的内容是 (112) ,第二行的内容是 (113) ,第三行的内容是 (114) 。

Private Sub Command1_click() Dim x As Integer, i As Integer x = 2

For i = 1 To 13 x = x * i

Print fun1(x, i) Next i End Sub

Private Function fun1(x As Integer, y As Integer) As Integer y = y + x fun1 = y \\ 2 End Function

49.执行下面的程序,在窗体上显示的输出结果的第一行是 (115) 。第三行是 (116) 。

Private Sub Command1_click() Dim x As Single, i As Integer x = 1.2

For i = 1 To 3

x = x * i Print fun1(x) Next i End Sub

Private Function fun1(x As Single) As Single Static y As Single y = y + x fun1 = y / 2 End Function

50.下列程序段运行后,单击窗体时变量y的值是 (117) ,变量n的值是 (118) 。

Private Sub Form_Click()

Dim m As Integer, n As Integer, y As Integer m = 3 n = 4

y = fun(m + 2, n) + m Print y; n End Sub

Private Function fun(a As Integer, b As Integer) a = a + b b = a - b fun = a + b End Function

51.下列程序段运行后,单击窗体时输出的第一行是 (119) ,第三行是 (120) 。

Private Sub Form_Click()

Dim a As Integer, b As Integer, c As Integer a = 1: b = 2

c = fun(a, fun(a, b)) Print a; b; c End Sub

Private Function fun(k As Integer, n As Integer) As Integer Print k; n; k = n + a + k n = k + a + n fun = k + n Print fun End Function

52.运行下面程序,单击窗体,则在窗体上显示的第一行内容是 (121) ,第二行内容是 (122) ,第三行内容是 (123) 。

Option Base 1

Private Sub Form_Click()

Dim a(5) As Integer, i As Integer, j As Integer For i = 1 To 5

a(i) = 2 * i - 1 Print a(i);


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

下一篇:水力学 各章专题浓缩(附详解)

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

马上注册会员

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