内容发布更新时间 : 2025/1/4 2:55:04星期一 下面是文章的全部内容请认真阅读。
填空题1
1. 执行下面程序,单击命令按钮Command1,则窗体上显示的第一行是 (1) ,最
后一行是 (2) 。 Option Explicit Option Base 1
Private Sub Command1_Click()
Dim n As Long, k As Integer, a() As Integer n = 123456789 Do
k = k + 1
ReDim Preserve a(k) a(k) = n Mod 100 n = n \\ 100
Loop Until n = 0 For k = 1 To UBound(a) Print fun(a(k)) Next k End Sub
Private Function fun(n As Integer) As Integer Dim k As Integer k = n Mod 10 fun = k * 10 + (n \\ 10) End Function 2. 执行下面程序,单击命令按钮Command1,则数组元素a(2, 1)的值是 (3) ,a(1,
2)的值是 (4) 。 Option Explicit Option Base 1
Private Sub Command1_Click()
Dim a(3, 3) As Integer, i As Integer, k As Integer Dim n As Integer n = 9 For k = 1 To 3
For i = 1 To 3 a(i, k) = n
n = n - 1 Next i Next k
For i = 1 To 3
For k = 1 To 3 Print a(i, k); Next k
Print Next i End Sub
3. 执行下面程序,单击命令按钮Command1,则窗体上显示的第一行是 (5) ,第
二行是
(6) ,第三行是 (7) 。 Option Explicit
Private Sub Command1_Click()
Dim i As Integer, a As Integer, b As Integer a = 1 b = 2 i = a
Do While fun(i, b) <= 7 i = i + a b = b + 1 Print i Loop End Sub
Private Function fun(ByVal x As Integer, y As Integer) As Integer x = x + 1
y = y + 1 fun = x + y Print fun End Function
4. 执行下面程序,单击命令按钮Command1,则窗体上显示的第一行是 (8) ,第
二行是
(9) ,最后一行是 (10) 。 Option Explicit
Dim k As Integer 'k为模块级变量 Private Sub Command1_Click()
Dim N As Integer, M As Integer, Lcm As Integer N = 6 M = 9
Lcm = Rec(N, M) Print Lcm End Sub
Private Function Rec(A As Integer, B As Integer) As Integer k = k + 1 Print A
If A Mod B = 0 Then Rec = A Else
Rec = Rec(A + A / k, B) End If End Function
2
5. 执行下面程序,单击命令按钮Command1,则窗体上显示的第一行是 (1) ,第
三行是
(2) 。 Option Explicit Option Base 1
Private Sub Command1_Click() Dim s As String, k As Integer
Dim q As String, a() As String, n As Integer s = \ n = 1 Do
k = k + 1
ReDim Preserve a(k) a(k) = Mid(s, n, n) n = n + 1
Loop While n + Len(a(k)) <= Len(s) For n = 1 To UBound(a) q = \
Call sub1(a(n), q) Print q Next n End Sub
Private Sub sub1(s As String, q As String) Dim i As Integer For i = 1 To Len(s)
q = Mid(s, i, 1) & q Next i End Sub
6. 执行下面程序,单击命令按钮Command1,则数组元素a(1, 2)的值是 (3) ,a(3,1)
的值是
(4) 。 Option Explicit Option Base 1
Private Sub Command1_Click()
Dim a(3, 3) As Integer, i As Integer, j As Integer For i = 1 To 3
For j = 1 To 3
If (i + j) Mod 2 = 0 Then