高手帮我改正下VB

来源:百度知道 编辑:UC知道 时间:2024/05/22 07:13:09
Private Sub Form_Load()
Dim counts As Integer
Text1.Text = ""

End Sub

Private Sub Text1_KeyPress(KeyAsc As Integer)
If KeyAsc = 13 Then
Do
If Text1.Text = "333" Then
Print "welcome"
counts = 0
Exit Sub
Else
counts = counts + 1
If counts = 3 Then

MsgBox "对不起,您不能使用本系统!", vbOKOnly + vbInformation, "haha"
End
End If
MsgBox "密码错误!请重新输入密码."

End If
Loop
End If
End Sub
循环出现问题,请修改,谢谢!!!

将Counts改写为全定义变量,然后去掉do循环,

Dim counts As Integer

Private Sub Form_Load()

counts = 0
Text1.Text = ""

End Sub

Private Sub Text1_KeyPress(KeyAsc As Integer)
If KeyAsc = 13 Then
If Text1.Text = 333 Then
Print "welcome"
Exit Sub
Else
counts = counts + 1
End If
If counts = 3 Then
MsgBox "对不起,您不能使用本系统!", vbOKOnly + vbInformation, "haha"
End
End If
MsgBox "密码错误!请重新输入密码."
End If

End Sub

靠~!~气死我了~!害我弄了那么久~!~哈~!~把If counts = 3 Then 改成
If counts = 2Then
就行啦~!!@~哈~!~