下列代码执行的结果是( )。 Private Sub Form_Click() Dim a(5) Dim i as Integer For i = 1 To 5
a(i) = i + 2 Next i Print a(4) End Sub
A: 6
B: 8
C: 24
D: 2
a(i) = i + 2 Next i Print a(4) End Sub
A: 6
B: 8
C: 24
D: 2
举一反三
- 下列程序的运行结果为( )。Private Sub Command1_Click() Dim a(5) As String Dim i As Integer For i = 0 To 5 a(i) = i + 1 Print a(i); Next iEnd Sub A: 123456 B: 6 C: 1 2 3 4 5 6 D: 0
- 以下程序的运行结果是 Sub s1(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 For i = 1 To 4 a(i) = i + 5 Next i s1 a() For i = 1 To 4 Print a(i) Next i End Sub
- 运行下面的程序,第二行显示结果是___________。 Private Sub Form_Click() Dim A As Integer Dim i As Integer A = 5 For i = 1 To 9 Call sub1(i, A) Print i, A Next i End Sub Private Sub sub1(x As Integer, y As Integer) Static N As Integer Dim I As Integer For I = 3 To 1 Step -1 N = N + x x = x + 2 Next I y = y + N End Sub
- 下列程序的运行结果为( )。 Private Sub Command1_Click() Dim a(5) As String Dim i As Integer For i = 0 To 5 a(i) = i + 1 Print a(i); Next i End Sub
- 阅读程序: Option Base 1 Sub P(b() As Integer) For i=1 To 4 b(i)=2*i Next i End Sub Private Sub Form_Click() Dim a(4)As Integer For i=1 To 4 a(i)=i+4 Next i P a For i=1 To 4 Print a(i) Next i End Sub 运行上面的程序,单击窗体,输出结果为 A: 2 4 6 8 B: 5 6 7 8 C: 10 12 14 16 D: 4 8 12 16