VB用户登录实例

来源:百度知道 编辑:UC知道 时间:2024/06/22 23:37:59
Option Explicit
Public intmytimes As Integer
Const maxtimes As Integer = 3

Private Sub Form_Load()
intmytimes = 1
cbousername.AddItem "管理员"
cbousername.AddItem "操作员1"
cbousername.AddItem "操作员2"
End Sub
Private Sub cmdok_Click()
If cbousername.Text <> "" Then
If txtpassword.Text = "" Then
MsgBox "请输入密码", , "提示信息"
txtpassword.SetFocus
Exit Sub
End if
If txtpassword.Text <> "11" Then
If intmytimes > maxtimes Then
MsgBox "您无权使用该软件!", , "提示窗口"
End
Else
intmytimes = intmytimes + 1
MsgBox "密码不正确,请重新输入!", , "提示窗口"
txtpassword.SetFocus
Else
MsgBox "登录成功!", , "提示窗口"
End If
Else
MsgBox "操作员不能为空!", , "提示窗口"
Exit Sub
End If
End Sub
Private Sub cmdcancel_Click()

Option Explicit
Public intmytimes As Integer
Const maxtimes As Integer = 3
Private Sub Form_Load()
intmytimes = 1
cbousername.AddItem "管理员"
cbousername.AddItem "操作员1"
cbousername.AddItem "操作员2"
End Sub
Private Sub cmdok_Click()
If cbousername.Text <> "" Then
If txtpassword.Text = "" Then
MsgBox "请输入密码", , "提示信息"
txtpassword.SetFocus
Exit Sub
End If
If txtpassword.Text <> "11" Then
If intmytimes > maxtimes Then
MsgBox "您无权使用该软件!", , "提示窗口"
End
Else
intmytimes = intmytimes + 1
MsgBox "密码不正确,请重新输入!", , "提示窗口"
txtpassword.SetFocus
End If '*