有谁帮做一下这套VB题

来源:百度知道 编辑:UC知道 时间:2024/06/22 19:25:14
设计口令检测界面,口令自定,要求输入口令长度不超过8个字符,运行初始效果如图a所示。运行时,当用户输入完口令并按回车键或者按“确定”按钮时,都可以对口令进行判断。当输入正确口令时,将显示另一个欢迎窗口,如图b所示,否则,在原口令检测界面的窗体标题上显示“口令错,请再次输入口令!”,如图c所示。在连接三次输入错误口令后,给出警告,并退出应用程序。

Dim i As Integer
Private Sub Command1_Click()
i = i + 1
If i = 3 Then
MsgBox "连续三次输入错误,程序退出。", vbCritical, "退出"
End
End If
If Text1.Text = "123" Then '123是你设置的口令
form2.Show '欢迎界面
Else
MsgBox "口令错,请再次输入口令!", vbExclamation, "错误的口令"
Text1.SetFocus
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
i = i + 1
If i = 3 Then
MsgBox "连续三次输入错误,程序退出。", vbCritical, "退出"
End
End If
If Text1.Text = "123" Then '123是你设置的口令
form2.Show '欢迎界面
Else
MsgBox "口令错,请再次输入口令!", vbExclamation, "错误的口令"
Text1.SetFocus
End If
End If
End Sub