展开全部
我以前答问题时写的,你可以参考一下呵.
Dim PassNum%
Private Sub Command1_Click()
If PassNum > 3 Then
MsgBox "超过尝试次数!! 程序将被关闭!!"
End
End If
If Text1 = "123456" Then
MsgBox "密码正确,允许登录"
Else
Text1 = ""
PassNum = PassNum + 1
MsgBox "密码错误,你还有" & 3 - PassNum & "次机会了."
Text1.SetFocus
End If
End Sub
Private Sub Form_Load()
PassNum = 0
Text1 = ""
Text1.PasswordChar = "*"
Text1.MaxLength = 6
Command1.Caption = "登录"
Command1.Default = True
Me.Show
Text1.SetFocus
End Sub
Dim PassNum%
Private Sub Command1_Click()
If PassNum > 3 Then
MsgBox "超过尝试次数!! 程序将被关闭!!"
End
End If
If Text1 = "123456" Then
MsgBox "密码正确,允许登录"
Else
Text1 = ""
PassNum = PassNum + 1
MsgBox "密码错误,你还有" & 3 - PassNum & "次机会了."
Text1.SetFocus
End If
End Sub
Private Sub Form_Load()
PassNum = 0
Text1 = ""
Text1.PasswordChar = "*"
Text1.MaxLength = 6
Command1.Caption = "登录"
Command1.Default = True
Me.Show
Text1.SetFocus
End Sub
参考资料: http://hi.baidu.com/%C4%DD%BF%C9%B1%A6%B1%B4
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询