登录界面的设计

来源:互联网 发布:初中生学编程考试 编辑:程序博客网 时间:2024/05/21 10:22




代码如下
Option Explicit
Const MaxLoginTimes As Integer = 3
Private Sub cmdLogin_Click()
    Static loginTimes As Integer
    loginTimes = loginTimes + 1
If loginTimes < MaxLoginTimes Then
    On Error GoTo ppp
    Dim Cn As Connection
    Dim Rs As Recordset
    Dim strSQL As String
    
    Set Cn = New Connection
    Set Rs = New Recordset
    Cn.ConnectionString = " provider=Microsoft.Jet.OLEDB.3.51;Data Source=C:\Users\jf\Desktop\TestExample.mdb"
    Cn.Open
    Rs.ActiveConnection = Cn
    strSQL = "select UserPassword from UserInformation where UserID= '" & Me.txtUserID.Text & "'"
    Rs.Open (strSQL)
    If Rs.EOF = True Then
        MsgBox txtUserID.Text & "不存在"
        Me.txtUserID.SetFocus
        Me.txtUserID.SelStart = 0
        Me.txtUserID.SelLength = Len(Me.txtUserID.Text)
    Else
       If Rs.Fields("UserPassword").Value = Me.txtPassword.Text Then
            MsgBox "登录成功"
            Unload Me
            'frmNew.show
       Else
        MsgBox "密码错误"
       End If
     End If
        
ppp:
    Cn.Close
Else
    MsgBox "亲,您的输入次数超过允许的最大次数", vbCritical, "登录"
End If
End Sub

0 0
原创粉丝点击