📄 frmlogin.frm
字号:
VERSION 5.00
Begin VB.Form frmLogin
BorderStyle = 3 'Fixed Dialog
Caption = "登录"
ClientHeight = 2340
ClientLeft = 2835
ClientTop = 3480
ClientWidth = 3585
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1382.55
ScaleMode = 0 'User
ScaleWidth = 3366.121
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox txtUserName
Height = 345
Left = 1650
TabIndex = 1
Top = 855
Width = 1365
End
Begin VB.CommandButton cmdOK
Caption = "确定"
Default = -1 'True
Height = 390
Left = 360
TabIndex = 4
Top = 1740
Width = 1140
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消"
Height = 390
Left = 1980
TabIndex = 5
Top = 1740
Width = 1140
End
Begin VB.TextBox txtPassword
Height = 345
IMEMode = 3 'DISABLE
Left = 1650
PasswordChar = "*"
TabIndex = 3
Top = 1245
Width = 1365
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "日常开支管理系统"
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 495
Left = 240
TabIndex = 6
Top = 120
Width = 3135
End
Begin VB.Label lblLabels
Caption = "用户名称(&U):"
Height = 270
Index = 0
Left = 465
TabIndex = 0
Top = 870
Width = 1080
End
Begin VB.Label lblLabels
Caption = "密码(&P):"
Height = 270
Index = 1
Left = 465
TabIndex = 2
Top = 1260
Width = 1080
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public Success As Boolean
Private Sub cmdcancel_Click()
'设置全局变量为 false
'不提示失败的登录
Success = False
Me.Hide
End Sub
Private Sub cmdok_Click()
Dim txtsql As String
Dim password As String
Dim db As Database
Dim rs As Recordset
Set db = OpenDatabase(App.Path & "\payout.mdb")
Set rs = db.OpenRecordset("select * from User")
'判断用户名和密码是否和都正确
If Trim$(txtusername.Text) = "" Then
MsgBox "用户名不能为空,请输入用户名!", vbOKOnly + vbInformation, "提示"
txtusername.SetFocus
Else
txtsql = "select * from user where user_name='" & txtusername.Text & "'"
username = Trim(txtusername.Text)
Set rs = db.OpenRecordset(txtsql)
If rs.EOF = True Then
MsgBox "用户名不存在,请重新输入用户名!", vbOKOnly + vbInformation, "提示"
txtusername.Text = ""
txtpassword.Text = ""
txtusername.SetFocus
Else
If Trim$(rs.Fields(2)) = Trim$(txtpassword.Text) Then
Success = True
rs.Close
Me.Hide
Else
MsgBox "输入的密码不正确,请重新输入!", vbOKOnly + vbInformation, "提示"
txtpassword.Text = ""
txtpassword.SetFocus
End If
End If
End If
End Sub
Private Sub Form_Load()
Success = False
End Sub
Private Sub txtpassword_GotFocus()
cmdok.Default = True
End Sub
Private Sub txtpassword_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
SendKeys "{TAB}"
End If
End Sub
Private Sub txtusername_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtpassword.SetFocus
End If
cmdok.Default = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -