📄 frmlogin.frm
字号:
VERSION 5.00
Object = "{BA513CF3-1BFD-4976-B2DA-2F1A208D11F9}#1.0#0"; "vkusercontrolsxp.ocx"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
Begin VB.Form frmLogin
Caption = "用户登入"
ClientHeight = 2100
ClientLeft = 60
ClientTop = 420
ClientWidth = 4680
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "frmLogin.frx":0000
KeyPreview = -1 'True
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2100
ScaleWidth = 4680
StartUpPosition = 2 '屏幕中心
Begin MSComDlg.CommonDialog CommonDialog1
Left = 3960
Top = 840
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin vkUserContolsXP.vkTextBox Text1
Height = 300
Left = 1560
TabIndex = 1
Top = 840
Width = 1935
_ExtentX = 3413
_ExtentY = 529
BeginProperty LegendFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
PassWordChar = "*"
ScrollBars = 0
LegendForeColor = 16639672
End
Begin vkUserContolsXP.vkCommand vkCommand2
Height = 375
Left = 2520
TabIndex = 3
Top = 1560
Width = 1215
_ExtentX = 2143
_ExtentY = 661
BackColorPushed1= 16514043
BackColorPushed2= 14474460
Caption = "取消"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Picture = "frmLogin.frx":038A
End
Begin vkUserContolsXP.vkCommand vkCommand1
Height = 375
Left = 960
TabIndex = 2
Top = 1560
Width = 1215
_ExtentX = 2143
_ExtentY = 661
BackColorPushed1= 16514043
BackColorPushed2= 14474460
Caption = "确认"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Picture = "frmLogin.frx":0724
End
Begin VB.ComboBox Combo1
Height = 345
Left = 1560
TabIndex = 0
Top = 360
Width = 1935
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "密 码"
Height = 225
Left = 720
TabIndex = 5
Top = 840
Width = 450
End
Begin VB.Image Image2
Height = 240
Left = 360
Picture = "frmLogin.frx":0ABE
Top = 840
Width = 240
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "用户名"
Height = 225
Left = 720
TabIndex = 4
Top = 360
Width = 540
End
Begin VB.Image Image1
Height = 240
Left = 360
Picture = "frmLogin.frx":0E48
Top = 360
Width = 240
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 bOK As Boolean
Public bCancel As Boolean
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then Me.Hide
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 116 Then
'SaveSetting App.EXEName, "Settings", "FirstRun", "True"
'MyAppInfo.DataPath = App.Path & "\data.mdb"
End If
End Sub
Private Sub Form_Load()
On Error GoTo ErrFlag
Dim ConnTemp As New ADODB.Connection
Dim RSTemp As New ADODB.Recordset
Dim strSQL As String, i As Long
Combo1.Text = Environ("username")
strSQL = "Select * from userlist"
ConnTemp.Open StrConn
RSTemp.Open strSQL, ConnTemp, adOpenStatic, adLockReadOnly
For i = 1 To RSTemp.RecordCount
Combo1.AddItem RSTemp("UserName")
RSTemp.MoveNext
Next
RSTemp.Close
ConnTemp.Close
Set RSTemp = Nothing
Set ConnTemp = Nothing
bOK = False
Exit Sub
ErrFlag:
MsgBox "[登入]" & Err.Description, vbOKOnly + vbCritical
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Call vkCommand1_Click
End Sub
Private Sub vkCommand1_Click()
On Error GoTo ErrFlag
Dim ConnTemp As New ADODB.Connection
Dim RSTemp As New ADODB.Recordset
Dim strSQL As String, i As Long
With MyAppInfo
.UserName = Trim(Combo1.Text)
.UserName = Replace(.UserName, "%", "")
.UserName = Replace(.UserName, "*", "")
.UserName = Replace(.UserName, "=", "")
.UserName = Replace(.UserName, ">", "")
.UserName = Replace(.UserName, "<", "")
.UserName = Replace(.UserName, " ", "")
.UserName = Replace(.UserName, "'", "")
End With
strSQL = "Select * from userlist Where UserName='" & MyAppInfo.UserName & "'"
ConnTemp.Open StrConn
RSTemp.Open strSQL, ConnTemp, adOpenStatic, adLockReadOnly
If RSTemp.RecordCount <= 0 Then
MsgBox "[" & MyAppInfo.UserName & "] 该用户名不存在,请联络管理员", vbOKOnly + vbInformation
Else
If InStr(Text1.Text, RSTemp("Password")) > 0 And InStr(RSTemp("Password"), Text1.Text) > 0 Then
bOK = True
MyAppInfo.UserPW = Text1.Text
MyAppInfo.UserOP = RSTemp("OP")
Else
MsgBox "密码错误,请重新输入", vbOKOnly + vbInformation
With Text1
.SetFocus
.SelStart = 1
.SelLength = Len(.Text)
End With
End If
End If
RSTemp.Close
ConnTemp.Close
Set RSTemp = Nothing
Set ConnTemp = Nothing
If bOK = True Then Me.Hide
Exit Sub
ErrFlag:
MsgBox "[用户密码验证]" & Err.Description, vbOKOnly + vbCritical
End Sub
Private Sub vkCommand2_Click()
Me.Hide
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -