(23)在窗体上画一个命令按钮,名称为Command1,然后编写如下代码:
Option Base 0
Private Sub Command1_Click()
Dim A(4) As Integer,B(4) As Integer
For k = 0 To 2
A(k + 1) = InputBox("请输入一个整数")
B(3 - k) = A(k + 1)
Next k
Print B(k)
程序运行后,单击命令按钮,在输入对话框中分别输入2、4、6,输出结果为
A)0 B)2 C)3 D)4
(24)有以下程序:
Option Base 1
Dim arr() As Integer
Private Sub Form_Click()
Dim i As Integer, j As Integer
ReDim arr(3, 2)
For i = 1 To 3
For j = 1 To 2
arr(i, j) = i * 2 + j
Next j
Next i
ReDim Preserve arr(3, 4)
For j = 3 To 4
arr(3, j) = j + 9
Next j
Print arr(3, 2); arr(3, 4)
End Sub
程序运行后,单击窗体,输出结果为
A)8 13 B)0 13 C)7 12 D)0 0
(25)以下叙述中正确的是
A)一个Sub过程至少要有一个Exit Sub语句
B)一个Sub过程必须有一个End Sub语句
C)可以在Sub过程中定义一个Function过程,但不能定义Sub过程
D)调用一个Function过程可以获得多个返回值
(26)有以下程序:
Sub subP(b() As Integer)
For i = 1 To 4
b(i) = 2 * i
Next i
End Sub
Private Sub Command1_Click()
Dim a(1 To 4) As Integer
a(1) = 5
a(2) = 6
a(3) = 7
a(4) = 8
subP a()
For i = 1 To 4
Print a(i)
Next i
End Sub
运行上面的程序,单击命令按钮,输出结果为
A) |
2 |
B) |
5 |
C) |
10 |
D) |
出错 |
|
4 |
|
6 |
|
12 |
|
|
|
6 |
|
7 |
|
14 |
|
|
|
8 |
|
8 |
|
16 |
|
|
(27)设有如下通用过程:
Public Function Fun(xStr As String) As String
Dim tStr As String, strL As Integer