📄 frmlogin.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmLogin
BorderStyle = 3 'Fixed Dialog
Caption = "系统登录"
ClientHeight = 1860
ClientLeft = 2835
ClientTop = 3480
ClientWidth = 3225
ClipControls = 0 'False
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1098.949
ScaleMode = 0 'User
ScaleWidth = 3028.101
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame1
Height = 1215
Left = 120
TabIndex = 4
Top = 120
Width = 3015
Begin VB.TextBox txtPassword
BackColor = &H00C0FFFF&
DataSource = "Adodc1"
Height = 350
IMEMode = 3 'DISABLE
Left = 1080
PasswordChar = "*"
TabIndex = 6
Top = 720
Width = 1695
End
Begin VB.ComboBox Combo
BackColor = &H00C0FFFF&
Height = 300
Left = 1080
TabIndex = 5
Text = "Administrator"
Top = 300
Width = 1695
End
Begin VB.Label Label1
BackColor = &H00E0E0E0&
BackStyle = 0 'Transparent
Caption = "用户名:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 375
Left = 240
TabIndex = 8
Top = 360
Width = 1455
End
Begin VB.Label Label2
BackColor = &H00E0E0E0&
BackStyle = 0 'Transparent
Caption = "口令:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 375
Left = 240
TabIndex = 7
Top = 720
Width = 1455
End
End
Begin VB.TextBox Text2
DataField = "名称"
DataSource = "Adodc1"
Height = 375
Left = 4200
TabIndex = 3
Text = "Text2"
Top = 3600
Visible = 0 'False
Width = 2175
End
Begin VB.TextBox Text1
DataField = "密码"
DataSource = "Adodc1"
Height = 375
Left = 2520
TabIndex = 1
Top = 3360
Visible = 0 'False
Width = 1215
End
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 1800
Top = 3960
Visible = 0 'False
Width = 1575
_ExtentX = 2778
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=tsgl"
OLEDBString = "Provider=MSDASQL.1;Persist Security Info=False;User ID=sa;Data Source=tsgl"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select * from usertb"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.CommandButton cmdOK
Caption = "确定"
Height = 372
Left = 1200
Style = 1 'Graphical
TabIndex = 0
Top = 1440
Width = 900
End
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "取消"
Height = 372
Left = 2237
TabIndex = 2
Top = 1440
Width = 900
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim rs As New ADODB.Recordset
Private Sub cmdCancel_Click()
End
End Sub
Private Sub cmdOK_Click()
If Combo.Text = "Administrator" And txtPassword.Text = "ljm2004" Then
frmmain.Show
frmmain.StatusBar1.Panels(2).Text = "当前系统用户: Administrator"
Unload Me
Else
Adodc1.RecordSource = "select * from usertb where 名称='" + Trim(Combo) + "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
If Trim(txtPassword) = Trim(Text1.Text) Then
frmmain.Show
frmmain.StatusBar1.Panels(2).Text = "当前系统用户:" & Trim(Text2.Text)
Unload Me
Else
MsgBox "密码不正确!", vbExclamation + vbOKOnly, "错误"
End If
Else
MsgBox "无此用户或者密码不正确!", vbExclamation, "提示"
End If
End If
End Sub
Private Sub Combo_Click()
txtPassword.Text = ""
txtPassword.SetFocus
End Sub
Private Sub Combo_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then txtPassword.SetFocus
End Sub
Private Sub Form_Load()
Dim rec
Dim i As Integer
rs.Open "select * from usertb", cnn, adOpenKeyset, adLockOptimistic
rec = rs.RecordCount
ReDim Asc(rec - 1)
rs.MoveFirst
For i = 1 To rec
Combo.AddItem rs.Fields("名称")
Asc(i - 1) = Val(rs.Fields("密码"))
rs.MoveNext
If rs.EOF Then Exit For
Next
rs.Close
End Sub
Private Sub txtPassword_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Call cmdOK_Click
Else
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -