运行下列程序,单击窗体,在窗体上显示的结果为( )。Private Sub Form_Click() a = 0 n = 10 For i = 1 To n Step 2 a = a + 1 n = n + 5 Next i Print aEnd Sub
A: 20
B: 10
C: 5
D: 出错
A: 20
B: 10
C: 5
D: 出错
举一反三
- 下列程序代码的运行结果为( )。 Private Sub Command1_Click() For m = 1 To 10 Step 2 a = 10 For n = 1 To 20 Step 2 a = a + 2 Next n Next m Print a End Sub
- 运行下列程序,单击窗体显示的结果为( )。 Private Sub Form_Click() Dim a Dim s As Integer, i As Integer a = Array(1, 2, 3) For i = 2 To 0 Step -1 s = s + a(i) * a(i) Next i Print s End Sub
- 下列程序代码的运行结果为( )。Private Sub Command1_Click() For m = 1 To 10 Step 2 a = 10 For n = 1 To 20 Step 2 a = a + 2 Next n Next m Print aEnd Sub A: 60 B: 50 C: 30 D: 20
- 运行下面的程序,第二行显示结果是___________。 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 Form_Click() K = 1 For i = 5 To 1 Step -1 T = T * 10 + K S = S + T Next i Print SEnd Sub运行程序时,单击窗体后,显示的是 A: 12345 B: 54321 C: 0 D: 11111