单选题
VB
题号 #142627
在窗体上画一个名称为 Text1 的文本框和一个名称为 Commandl 的命令按钮,然后编写如下事件过程:
Private Commandl_Click()
Dim i As Integer, n As Integer
For i=0 To 50
i = i+3
n = n+1
If i>10Then Exit For
Next
Textl.Text=Str(n)
End Sub
程序运行后,单击命命令按钮,在文本框中显示的值是( )。
参考答案
C
答案解析
在此题中要注意Exit For语句,该语句是跳出循环体,变量n记录循环执行次数。由于循环跳出的条件是I>10,而I的步长为3,所以循环只执行了3次。
你可能感兴趣的试题
A.10 和 20
B.20 和 110
C.200 和 110
D.110 和 20
A.Privale Sub List1_Click()
Label1.Caption=List1. ListIndex
List1.Removeltem List1.Text
End Sub
Label1.Caption=List1. ListIndex
List1.Removeltem List1.Text
End Sub
B.Private Sub List1_Click()
Label1.Name=List1. ListIndex
List1.RemoveItem List1.Text
End Sub
Label1.Name=List1. ListIndex
List1.RemoveItem List1.Text
End Sub
C.Private Sub List1_Click()
Label1.Caption=List1.Text
List1.RemovItem List1.ListIndex
End Sub
Label1.Caption=List1.Text
List1.RemovItem List1.ListIndex
End Sub
D.Private Sub List1_Click()
Label1.Name=List1. Text
List1.RemoveItem List1. ListIndex
End Sub
Label1.Name=List1. Text
List1.RemoveItem List1. ListIndex
End Sub
A.
| 1 | 2 | 3 |
| 2 | 4 | 6 |
| 3 | 6 | 9 |
B.
| 2 | 3 | 4 |
| 3 | 4 | 5 |
| 4 | 5 | 6 |
C.
| 1 | 4 | 7 |
| 2 | 5 | 8 |
| 3 | 6 | 9 |
D.
| 1 | 2 | 3 |
| 4 | 5 | 6 |
| 7 | 8 | 9 |