📄 frmuser.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmUser
BorderStyle = 1 'Fixed Single
Caption = "添加用户"
ClientHeight = 2415
ClientLeft = 3210
ClientTop = 2730
ClientWidth = 4350
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2415
ScaleWidth = 4350
Begin VB.CommandButton cmdOk
Caption = "确认"
Default = -1 'True
Height = 312
Left = 660
TabIndex = 8
Top = 1920
Width = 1455
End
Begin VB.CommandButton cmdExit
Caption = "退出"
Height = 312
Left = 2220
TabIndex = 7
Top = 1920
Width = 1455
End
Begin VB.Frame Frame1
Appearance = 0 'Flat
ForeColor = &H80000008&
Height = 1635
Left = 240
TabIndex = 0
Top = 120
Width = 3855
Begin VB.TextBox txtPassword2
Height = 264
IMEMode = 3 'DISABLE
Left = 1560
PasswordChar = "*"
TabIndex = 3
Top = 1080
Width = 1935
End
Begin VB.TextBox txtPassword1
Height = 264
IMEMode = 3 'DISABLE
Left = 1560
PasswordChar = "*"
TabIndex = 2
Top = 720
Width = 1935
End
Begin VB.TextBox txtUserName
Height = 264
Left = 1560
TabIndex = 1
Top = 360
Width = 1935
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "请确认密码"
Height = 180
Left = 420
TabIndex = 6
Top = 1125
Width = 900
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "请输入密码"
Height = 180
Left = 420
TabIndex = 5
Top = 765
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "请输入用户名"
Height = 180
Left = 240
TabIndex = 4
Top = 405
Width = 1080
End
End
Begin MSAdodcLib.Adodc Adodc1
Height = 315
Left = 2880
Top = 2160
Visible = 0 'False
Width = 1455
_ExtentX = 2566
_ExtentY = 556
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Stud97.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Stud97.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
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
End
Attribute VB_Name = "frmUser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'添加用户窗体frmUser
Option Explicit
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdOk_Click() '确认
'检查各文本框是否为空
If Trim$(txtUserName.Text) = "" Then
MsgBox "请输入用户名!", vbExclamation
txtUserName.SetFocus
Exit Sub
End If
If Trim$(txtPassword1.Text) = "" Then
MsgBox "请输入密码!", vbExclamation
txtPassword1.SetFocus
Exit Sub
End If
If Trim$(txtPassword2.Text) = "" Then
MsgBox "请确认密码!", vbExclamation
txtPassword2.SetFocus
Exit Sub
End If
'检查两次输入密码是否一致
If Trim$(txtPassword1.Text) <> Trim$(txtPassword2.Text) Then
MsgBox "确认密码错误,请重新输入!", vbExclamation
With txtPassword2
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
Exit Sub
End If
'SQL语句作为ADO控件的记录源
Adodc1.RecordSource = "SELECT * FROM 用户 WHERE 用户名='" & txtUserName.Text & "'"
Adodc1.Refresh
With Adodc1.Recordset
If .BOF Then '检查是否有同名用户,若无,添加,若有,重新输入
.AddNew
.Fields(0) = Trim$(txtUserName.Text)
.Fields(1) = Trim$(txtPassword1.Text)
.Fields(2) = "普通" '默认权限为普通用户
.Update
MsgBox "添加用户成功!", vbInformation
Else
MsgBox "此用户已存在!", vbExclamation
With txtUserName '焦点返回用户框
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
Exit Sub
End If
End With
End Sub
Private Sub Form_Unload(Cancel As Integer) '窗体卸载时
frmMain.Show
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -