📄 frmadduser.frm
字号:
VERSION 5.00
Begin VB.Form frmAddUser
Caption = "添加新用户"
ClientHeight = 5955
ClientLeft = 60
ClientTop = 345
ClientWidth = 4980
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 5955
ScaleWidth = 4980
StartUpPosition = 1 '所有者中心
Begin VB.CommandButton cmdAddUser
Caption = "添加"
Height = 615
Left = 1680
TabIndex = 3
Top = 5040
Width = 1575
End
Begin VB.TextBox txtDetail
Height = 1815
Left = 720
TabIndex = 2
Top = 2760
Width = 3495
End
Begin VB.TextBox txtPasswd
Height = 495
IMEMode = 3 'DISABLE
Left = 2520
PasswordChar = "*"
TabIndex = 1
Top = 1440
Width = 1695
End
Begin VB.TextBox UserName
Height = 615
Left = 2520
TabIndex = 0
Top = 480
Width = 1695
End
Begin VB.Label Label4
Caption = "*"
Height = 255
Left = 4320
TabIndex = 7
Top = 600
Width = 255
End
Begin VB.Label Label3
Caption = "备注"
Height = 495
Left = 720
TabIndex = 6
Top = 2400
Width = 1575
End
Begin VB.Label Label2
Caption = "密码"
Height = 495
Left = 720
TabIndex = 5
Top = 1320
Width = 1455
End
Begin VB.Label Label1
Caption = "用户名"
Height = 495
Left = 720
TabIndex = 4
Top = 600
Width = 1455
End
End
Attribute VB_Name = "frmAddUser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub txtUserName_LostFocus()
If txtUserName.Text = "" Then
MsgBox "带星号为必添内容", , "Error"
txtUserName.SetFocus
End If
End Sub
Private Sub cmdAddUser_Click()
Dim sql As String
Dim rsRecordSet As New ADODB.Recordset
If Trim(UserName.Text) = "" Then
MsgBox "用户名不能为空", vbOKOnly + vbExclamation, ""
Exit Sub
UserName.SetFocus
Else
sql = "select * from employees"
rsRecordSet.Open sql, connConnection, adOpenKeyset, adLockPessimistic
While (rsRecordSet.EOF = False)
If Trim(rsRecordSet.Fields(1)) = Trim(UserName.Text) Then
MsgBox "已有这个用户", vbOKOnly + vbExclamation, ""
UserName.SetFocus
UserName.Text = ""
txtPasswd.Text = ""
txtDetail.Text = ""
Exit Sub
Else
rsRecordSet.MoveNext
End If
Wend
rsRecordSet.AddNew
rsRecordSet.Fields(1) = UserName.Text
rsRecordSet.Fields(2) = txtPasswd.Text
rsRecordSet.Fields(3) = txtDetail.Text
rsRecordSet.Update
rsRecordSet.Close
MsgBox "添加用户成功", vbOKOnly + vbExclamation, ""
Unload Me
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -