📄 loginform.frm
字号:
VERSION 5.00
Begin VB.Form frmlogin
Caption = "登录"
ClientHeight = 3120
ClientLeft = 60
ClientTop = 345
ClientWidth = 4560
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3120
ScaleWidth = 4560
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton cmdcancel
Caption = "取 消"
Height = 375
Left = 2760
TabIndex = 6
Top = 2160
Width = 1095
End
Begin VB.CommandButton CmdOK
Caption = "登 录"
Height = 375
Left = 1320
TabIndex = 5
Top = 2160
Width = 1095
End
Begin VB.TextBox txtPassword
Height = 375
IMEMode = 3 'DISABLE
Left = 1320
PasswordChar = "*"
TabIndex = 4
Top = 1560
Width = 2535
End
Begin VB.TextBox txtusername
Height = 375
Left = 1320
TabIndex = 3
Top = 960
Width = 2535
End
Begin VB.Label Label4
Alignment = 2 'Center
Caption = "二000级04届 毕业生:朱烽 设计"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = -1 'True
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000003&
Height = 375
Left = 240
TabIndex = 7
Top = 2760
Width = 4005
End
Begin VB.Label Label3
Alignment = 2 'Center
Caption = "密码:"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 2
Top = 1560
Width = 1095
End
Begin VB.Label Label2
Alignment = 2 'Center
Caption = "用户名:"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 1
Top = 960
Width = 1215
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "单位车辆管理系统"
BeginProperty Font
Name = "华文行楷"
Size = 18
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000002&
Height = 495
Left = 240
TabIndex = 0
Top = 240
Width = 4215
End
End
Attribute VB_Name = "frmlogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit '强制变量声明
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long
Public OK As Boolean
Dim micount As Integer '用于记录登陆次数
Private Sub cmdcancel_Click()
OK = False
Me.Hide
End Sub
Private Sub cmdok_Click()
Dim txtsql As String '用于存放SQL语句
Dim mrc As ADODB.Recordset '存放记录集对象
Dim msgtext As String '存放返回的信息
' Dim username As String
username = ""
password = ""
If Trim(txtusername.Text = "") Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtusername.SetFocus
Else
txtsql = "select * from users where user_id='" & Trim(txtusername.Text) & " '"
Set mrc = ExecuteSQL(txtsql, msgtext)
If mrc.EOF = True Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtusername.SetFocus
Else
If Trim(mrc.Fields(1)) = Trim(txtPassword.Text) Then
OK = True
mrc.Close
Me.Hide
username = Trim(txtusername.Text)
password = Trim(txtPassword.Text)
Else
MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtPassword.SetFocus
txtPassword.Text = ""
End If
End If
End If
End Sub
Private Sub Form_Load()
Dim sBuffer As String
Dim lSize As Long
sBuffer = Space$(255)
lSize = Len(sBuffer)
Call GetUserName(sBuffer, lSize)
If lSize > 0 Then
txtusername.Text = ""
Else
txtusername.Text = vbNullString
End If
OK = False
micount = 0
End Sub
Private Sub txtPassword_KeyDown(KeyCode As Integer, Shift As Integer)
EnterToTab KeyCode
End Sub
Private Sub txtusername_KeyDown(KeyCode As Integer, Shift As Integer)
EnterToTab KeyCode
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -