📄 login.txt
字号:
Private Sub Form_Activate()
Dim strSQL As String
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
rs.LockType = adLockOptimistic
rs.CursorType = adOpenKeyset
cnn.CursorLocation = adUseClient
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\kfgl.mdb"
cnn.Open
SQL = "select 用户名 from qxsz"
Set rs = cnn.Execute(SQL)
For i = 0 To rs.RecordCount - 1
Combo1.AddItem (rs.Fields(0))
rs.MoveNext
Next i
If Combo1.ListCount > 0 Then Combo1.ListIndex = 0
rs.Close
cnn.Close
End Sub
Private Sub Form_Load()
Combo1.Text = ""
Text2.Text = ""
End Sub
Private Sub DBCombo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
Text2.SetFocus
End If
End Sub
Private Sub DBCombo1_KeyPress(KeyAscii As Integer)
If Not ((KeyAscii >= Asc("a") And KeyAscii <= Asc("z")) Or (KeyAscii >= Asc("A") And KeyAscii <= Asc("Z")) Or (KeyAscii >= vbKey0 And KeyAscii <= vbKey9) Or (KeyAscii = vbKeyBack)) Then
KeyAscii = 0
End If
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
Command1.Visible = True
Command1.SetFocus
End If
If KeyCode = vbKeyDown Then
Command1.Visible = True
Command1.SetFocus
End If
If KeyCode = vbKeyUp Then
DBCombo1.SetFocus
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If Not ((KeyAscii >= Asc("a") And KeyAscii <= Asc("z")) Or (KeyAscii >= Asc("A") And KeyAscii <= Asc("Z")) Or (KeyAscii >= vbKey0 And KeyAscii <= vbKey9) Or (KeyAscii = vbKeyBack)) Then
KeyAscii = 0
End If
End Sub
Private Sub Command1_Click()
Static intlogtimes As Integer
Dim strSQL As String
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
rs.LockType = adLockOptimistic
rs.CursorType = adOpenKeyset
cnn.CursorLocation = adUseClient
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\kfgl.mdb"
cnn.Open
SQL = "SELECT 密码 FROM qxsz where 用户名='" & Combo1.Text & "'"
Set rs = cnn.Execute(SQL)
If Text2.Text <> rs.Fields(0) Then
MsgBox "密码错误!请重新输入!!", vbCritical, "登录验证"
intlogtimes = intlogtimes + 1
If intlogtimes >= 3 Then
MsgBox "您无权操作本系统!再见!", vbCritical, "无权限"
Unload Me
End If
Else
MsgBox "登陆成功!", vbMsgBoxRight, "登录验证"
Unload Me
Form2.Show
End If
rs.Close
cnn.Close
End Sub
Private Sub Command2_Click()
If MsgBox("你选择了退出系统登陆,退出将不能启动管理系统!" & vbCrLf & "是否真的退出?", vbYesNo, "登陆验证") = vbYes Then
Unload Me
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -