A 6 B 9 C 10 D 18
31715 运行下列程序,单击窗体后输出结果是( )。 C Private Sub Form_Click() Dim a
Dim i As Integer, j As Integer a = Array(1, 2, 3, 4, 5, 6) For i = 1 To a(5) j = j + 1 Next i Print j End Sub
A 0 B 5 C 6 D 程序出错
31716 能刚好存放如下方阵数据的数组声明语句是( C )。 1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9
A Dim A(9) as Single B Dim A(3,3) as Single C Dim A(-1 to 1, -5 to -3) as Single D Dim A(-3 to -1,5 to 7) as Integer
31717 子过程Sele 的形式参数为一数组,则以下定义语句正确的是( B )。 A Private Sub Sele(A(20) As integer) B Private Sub Sele(A() As integer) C Private Sub Sele(A(,) As integer)
D Private Sub Sele(ByVal A() As integer)
31718 以下定义数组或给数组元素赋值的语句中,正确的是( A )。 A Dim a As Variant a=Array(1,2,3,4,5) B Dim a(10) As Integer a=Array(1,2,3,4,5) C Dim %A(10) a(1)=\
D Dim a(3),b(3)As Integer a(0)=0:a(1)=1:a(2)=2: b=a
31719 设arr是一个上界为K的一维动态数组。能使arr元素个数增加1,但保留
数组中原有数据的语句是( D )。
A ReDim arr(K + 1) B ReDim Static arr(K + 1) C Public arr(1 To K + 1) D ReDim Preserve arr(K + 1) 31720 设数组下标从0开始,有如下过程Fun: Private Sub Fun(a() As Integer) Dim T
Dim J As Integer
J = (LBound(a) + UBound(a)) \\ 2 For i = LBound(a) To J
T = a(i): a(i) = a(UBound(a) - i): a(UBound(a) - i) = T
41
Next i End Sub
下列对其功能的叙述正确的是( C )。
A 该过程能对传入数组进行升序排序 B 该过程能对传入数组进行降序排序
C 该过程能对传入数组进行逆序存放 D 以上均不对
31721 窗体上有命令按钮Command1,编写下列事件过程: Private Sub Command1_Click() Dim a(10) As Integer Dim p(3) As Integer k = 1
For I = 1 To 10 a(I) = I Next I
For I = 1 To 3 p(I) = a(I * 3) Next I
For I = 1 To 3
k = k + p(I) * 2 Next I Print k End Sub
运行时,单击命令按钮,窗体将显示( D )。
A 15 B 13 C 30 D 37
31722 下列数组声明语句中正确的是(B)。
A) Dim a[3,4] as Integer B) Dim a(3,4) as Integer C) Dim a(n,4) as Integer D) Dim a(3 4) as Integer 31723 如下数组声明语句中数组a包含的元素个数为(A)。 Dim a(3, -1 To 1, 6)
A) 84 B) 54 C) 72 D) 18
31801 窗体上有两个文本框(Text1、Text2)和一个命令按钮(Command1),阅读如下程序:
Private Sub func(T As TextBox, a As Integer) T.Text = \ a = a * a End Sub
Private Sub Form_Load() Text1.Text = \ Text2.Text = 10 End Sub
Private Sub Command1_Click() Dim temp As Integer temp = Val(Text2.Text)
42
Call func(Text1, temp) Text2.Text = temp End Sub
运行后,单击按钮,Text1和Text2将分别显示(B )。 A ABCD和10 B 1234和100 C ABCD和100 D 1234和10
31802 窗体上有命令按钮Command1和Command2,请阅读下列程序: Dim a As Integer
Private Sub Command1_Click() a = a + 3 : Print a End Sub
Private Sub Command2_Click() a = a + 2 : Print a End Sub
运行时,分别单击Command1和Command2按钮,输出的结果为(A )。 A 3 5 B 3 2 C 2 5 D 2 3
31803 运行下列程序,单击窗体后输出的结果是( B)。 Function F(ByVal x As Integer) Static z
z = z + 1: x = x + z F = x + z End Function
Private Sub Form_Click() Dim a As Integer Dim i As Integer a = 2
For i = 1 To 3 Print F(a), Next i End Sub
A 4 7 11 B 4 6 8 C 4 4 4 D 4 5 6 31804 阅读下列程序: Sub Med(x%, ByVal y%) x = 3 * x: y = x + y End Sub
Private Sub Form_Click() Dim a%, b% a = 3: b = 8 Med a, b Print a, b End Sub
运行后,单击窗体,输出结果为( C)。
43
A 3 8 B 3 17 C 9 8 D 9 17 31805 阅读下列程序: Private Sub Form_Click() Dim m As Integer Static n As Integer For i = 1 To 3 n = n + i
m = m + i ^ 2 Next
Print m, n End Sub
运行时,两次单击窗体,输出结果为(B )。
A 14 6 14 6 B 14 6 14 12 C 14 6 28 6 D 14 6 28 12
31806 窗体上有一个命令按钮Command1,编写如下事件过程: Private Sub Command1_Click() Dim i%, j%, x%, n% x = 0
n = InputBox(\ For i = 1 To n For j = 1 To i x = x + j Next j Next i Print x End Sub
运行时,单击命令按钮,如果在输入对话框中输入3,则窗体上显示的内容是( B)。 A 6 B 10 C 14 D 18 31807 阅读如下程序,
Dim S As Single, a As Single, b As Single a = 1: b = 2 plus S, a, b Print S
不能使其输出结果为3的plus过程为( B)。 A Sub plus(sum As Single, a As Single, b As Single) sum = a + b End Sub
B Sub plus(ByVal sum As Single, a As Single, b As Single) sum = a + b End Sub
C Sub plus(ByRef sum As Single, ByVal a As Single, ByVal b As Single) sum = a + b End Sub
44