我想用VB做个帐号和密码输入框?

来源:百度知道 编辑:UC知道 时间:2024/06/30 02:49:26
用VB做个帐号密码输入框,但怎么才能做到密码和帐号只能登录5次,登录5次后密码就变成了错误了,也就是说不能登录了
永远都不能登录了,永远密码都是错误的

还是我来吧~代码如下,初始化已经做好了哦,直接粘贴即可实现:
您只需在Form中添加以下控件即可:
2个Label控件,2个TextBox控件,2个CommandButton控件.

Dim NCount As Integer

Private Sub Command1_Click()
If NCount > 4 Then
SaveSetting "VB", "Settings", "NCount", NCount
MsgBox "超过输入次数,无法登录系统!", , Me.Caption
Exit Sub
End If
If Text1.Text = "123" And Text2.Text = "123" Then
MsgBox "登录成功!", , Me.Caption
Else
MsgBox "账号或密码错误,请重新输入!", , Me.Caption
NCount = NCount + 1
End If
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Form_Load()
Label1.Caption = "账号:"
Label2.Caption = "密码:"
Text1.Text = ""
Text2.Text = ""
Command1.Caption = "确定"
Command2.C