单选题
VB
题号 #2272663
窗体上有一-个Text1文本框,一个Command1命令按钮,并有以下程序:
Private Sub Command1 Click( )
Dim n
If Text1.Text<>"123456"Then
n=n+1
Print"口令输入错误”&n&”次"
End If
End Sub

希望程序运行时得到左图所示的效果,即:输入口令,单击“确定口令’’命令按钮,若输入的口令不是“123456”,则在窗体上显示输入错误口令的次数。但上面的程序实际显示的是右图所示的效果,程序需要修改。下面修改方案中正确的是( )。
参考答案
D
答案解析
D。【解析】本题要实现的功能是当输入错误口令时,在窗体上显示输入错误口令的次数,本题若要正确记录输入错误的次数,应把n定义成静态变量n。
你可能感兴趣的试题
A.Private Sub P1 MouseMove(Button As Integer,Shift As Integer,X As Single,Y
As Single)
Print X Y
End Sub
As Single)
Print X Y
End Sub
B.Private Sub P1 MouseDown(Button As Integer,Shift As Integer,X As Single,Y
As Single)
Picture.Print X,Y
End Sub
As Single)
Picture.Print X,Y
End Sub
C.Private Sub P1 MouseMove(Button As Integer,Shift As Integer,X As Single,Y
As Single)
P1.Print X,Y
End Sub
As Single)
P1.Print X,Y
End Sub
D.Private Sub Form MouseMove(Button As Integer,Shift As Integer,X As Single,Y
As Single)
P1.Print X,Y
End Sub
As Single)
P1.Print X,Y
End Sub
A.把For k=3 To n改为For k=1 To n
B.把n=20000改为n=20000000
C.把For k=3 To n改为For k=3 To n Step 2
D.把PI=1改为P1=0
A.13+23+33+…+103的值
B.10!+…+3!+2!+1!的值
C.(1+2+3+…+10)3的值
D.10个103的和