问一个VB6.0的问题

来源:百度知道 编辑:UC知道 时间:2024/06/10 03:45:05
Private Sub Command1_Click()
Dim LoginName, Password As String
LoginName = txtUserName.Text
Password = txtPassword.Text
Use = Use + 1
If LoginName = "harl" And Password = 1 Then
Message.Caption = "Welcom"
ElseIf Use < 4 Then
Message.Visible = True
Message.Caption = "Incorrect UserName or Passward.Please try again"
Else
Message.Caption = "Unauthorized access.Aborting……"
End
End If
End Sub
我想要输入密码输入错误3次就退出程序但是调试不成功。。。

这样就行了 把Use声明在通用里 这样在点击COMMAND1时 Use的值就会在原来的数值+1 而Use的值不会一值为0

Dim Use As Integer
Private Sub Command1_Click()
Dim LoginName, Password As String
LoginName = T.Text
Password = Tx.Text
Use = Use + 1
If LoginName = "harl" And Password = "1" Then
message.Caption = "Welcom"
ElseIf Use < 4 Then
message.Visible = True
message.Caption = "Incorrect UserName or Passward.Please try again"
Else
message.Caption = "Unauthorized access.Aborting……"
End
End If
End Sub

use是用来存储尝试次数的吧,应该将这个变量变为static即可。