📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form 登陆界面
Caption = "登陆界面"
ClientHeight = 4440
ClientLeft = 4245
ClientTop = 3570
ClientWidth = 6525
ForeColor = &H00000000&
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 4440
ScaleWidth = 6525
Begin VB.Frame Frame1
Caption = "用户登陆"
Height = 3375
Left = 720
TabIndex = 0
Top = 360
Width = 4935
Begin VB.CommandButton Command2
Cancel = -1 'True
Caption = "退 出"
Height = 615
Left = 3000
TabIndex = 4
Top = 2400
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "登 陆"
Height = 615
Left = 600
TabIndex = 3
Top = 2400
Width = 1215
End
Begin VB.TextBox Text2
Height = 375
IMEMode = 3 'DISABLE
Left = 1680
PasswordChar = "*"
TabIndex = 2
Top = 1560
Width = 2175
End
Begin VB.TextBox Text1
Height = 375
Left = 1680
TabIndex = 1
Top = 600
Width = 2175
End
Begin VB.Label Label2
Caption = "密 码"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 720
TabIndex = 6
Top = 1680
Width = 855
End
Begin VB.Label Label1
Caption = "帐 号"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 720
TabIndex = 5
Top = 720
Width = 735
End
End
End
Attribute VB_Name = "登陆界面"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Form_Load()
Dim mypath As String
Set cnn = New ADODB.Connection
Set rs = New ADODB.Recordset
mypath = App.Path & "/data" '获取当前路径
If Right(mypath, 1) <> "/" Then mypath = mypath + "/"
cnn.Open "Data Source=" & mypath & "db1.mdb" & ";Provider=Microsoft.Jet.OLEDB.4.0 " '连接并打开数据库
End Sub
Private Sub Command1_Click()
If Text1.Text <> "" And Text2.Text <> "" Then
strsql = "select * from 用户信息 where 用户名='" & Text1.Text & "' and 密码='" & Text2.Text & "'"
Set rs = cnn.Execute(strsql)
If Not rs.EOF Then '输入的登录信息正确,则进入系统
主界面.Show
Unload 登陆界面
Else
MsgBox "您输入的登录信息有误,请重新输入!", vbOKOnly + vbExclamation, "提示"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End If
Else
MsgBox "您输入的帐号或密码有误!", vbOKOnly + vbExclamation, "警告"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End If
End Sub
Private Sub Command2_Click()
i = MsgBox("确实要退出系统吗?", vbYesNo + vbExclamation, "系统警告")
If i = vbYes Then
End
Else
MsgBox "欢迎继续使用!", vbOKOnly, "系统提示"
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then '监听键盘回车
Command1.Value = True
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then '监听键盘回车
Command1.Value = True
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -