📄 adduser.frm
字号:
VERSION 5.00
Begin VB.Form frmadduser
Caption = "添加用户"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 1 '所有者中心
Begin VB.CommandButton cmdcancel
Caption = "退出"
Height = 435
Left = 2640
TabIndex = 7
Top = 2490
Width = 1215
End
Begin VB.CommandButton cmdok
Caption = "添加用户"
Height = 435
Left = 930
TabIndex = 6
Top = 2490
Width = 1215
End
Begin VB.TextBox txtpassword2
Height = 495
IMEMode = 3 'DISABLE
Left = 2220
PasswordChar = "*"
TabIndex = 2
Top = 1740
Width = 1755
End
Begin VB.TextBox txtpassword1
Height = 495
IMEMode = 3 'DISABLE
Left = 2250
PasswordChar = "*"
TabIndex = 1
Top = 1110
Width = 1755
End
Begin VB.TextBox txtusername
Height = 495
Left = 2220
TabIndex = 0
Top = 420
Width = 1755
End
Begin VB.Label Label3
Alignment = 1 'Right Justify
Caption = "请确认密码:"
Height = 465
Left = 660
TabIndex = 5
Top = 1860
Width = 1545
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
Caption = "请输入密码:"
Height = 465
Left = 750
TabIndex = 4
Top = 1200
Width = 1455
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "请输入用户名:"
Height = 435
Left = 780
TabIndex = 3
Top = 510
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 cmdcancel_Click()
Unload Me
End Sub
Private Sub cmdok_Click()
' Label4.Caption = username_OK
Dim txtsql As String
Dim mrc As ADODB.Recordset
Dim msgtext As String
If Trim(txtusername.Text) = "" Then '判断输入用户名是否为空
MsgBox "请输入用户名称!", vbOKOnly, "警告"
Exit Sub
End If
'判断输入的密码是否一致
If Trim(txtpassword1.Text) <> Trim(txtpassword2.Text) Then
MsgBox "两次输入密码不一样,请确认!", vbOKOnly, "警告"
Exit Sub
End If
If Len(txtpassword1.Text) = 0 Then '判断输入密码是否为空
MsgBox "输入密码不能为空!", vbOKOnly, "警告"
Exit Sub
End If
'判断帐号在数据库中是否已存在
txtsql = "select * from user_info where user_ID='" & txtusername.Text & "'"
Set mrc = ExecuteSQL(txtsql, msgtext)
If mrc.EOF Then
'为新的账号,加入数据库中
mrc.AddNew
mrc.Fields("user_ID") = Trim(txtusername.Text)
mrc.Fields("user_PWD") = Trim(txtpassword1.Text)
mrc.Update
mrc.Close
MsgBox "添加用户成功!", vbOKOnly, "添加用户"
Else
'账号在数据库已存有
MsgBox "用户已经存在,请重新输入用户名!", vbOKOnly, "警告"
Exit Sub
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -