📄 frmadduser.frm
字号:
VERSION 5.00
Begin VB.Form frmAddUser
Caption = "添加用户"
ClientHeight = 4995
ClientLeft = 60
ClientTop = 345
ClientWidth = 6420
LinkTopic = "Form1"
ScaleHeight = 4995
ScaleWidth = 6420
Begin VB.CommandButton cmdCancel
Caption = "取消"
Height = 495
Left = 3840
TabIndex = 7
Top = 4080
Width = 1335
End
Begin VB.CommandButton cmdOK
Caption = "确认"
Height = 495
Left = 1320
TabIndex = 6
Top = 4080
Width = 1335
End
Begin VB.TextBox Text3
Height = 495
IMEMode = 3 'DISABLE
Left = 2520
PasswordChar = "*"
TabIndex = 5
Top = 2520
Width = 2655
End
Begin VB.TextBox Text2
Height = 495
IMEMode = 3 'DISABLE
Left = 2520
PasswordChar = "*"
TabIndex = 4
Top = 1560
Width = 2655
End
Begin VB.TextBox Text1
Height = 495
Left = 2520
TabIndex = 3
Top = 480
Width = 2655
End
Begin VB.Label Label3
Caption = "请确认密码"
Height = 375
Left = 480
TabIndex = 2
Top = 2640
Width = 1695
End
Begin VB.Label Label2
Caption = "请输入密码"
Height = 375
Left = 480
TabIndex = 1
Top = 1680
Width = 1695
End
Begin VB.Label Label1
Caption = "请输入用户名"
Height = 375
Left = 480
TabIndex = 0
Top = 600
Width = 1335
End
End
Attribute VB_Name = "frmAddUser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdOK_Click()
Dim txtSQL As String
Dim mrc As ADODB.Recordset
Dim msgText As String
'判断是否为空
If Trim(Text1.Text) = "" Then
MsgBox "请输入用户名!", vbOKOnly + vbInformation, "警告!"
Exit Sub
Text1.SetFocus
Else
txtSQL = "select*from user_info"
Set mrc = ExecuteSQL(txtSQL, msgText)
'判断数据集是否为空
While (mrc.EOF = False)
'判断是否有重复记录
If Trim(mrc.Fields(0)) = Trim(Text1) Then
MsgBox "用户已存在,请重新输入!", vbOKOnly + vbExclamation, "警告!"
Text1.Text = ""
Text1.SetFocus
Text2.Text = ""
Text3.Text = ""
Exit Sub
Else
mrc.MoveNext
End If
Wend
End If
'判断两次输入密码是否一致
If Trim(Text1.Text) <> Trim(Text2.Text) Then
MsgBox "两次输入密码不一致,请确认!", vbOKCancel + vbInformation, "警告!"
Text2.Text = ""
Text2.SetFocus
Text3.Text = ""
Exit Sub
Else
'判断输入密码是否为空
If Text1.Text = "" Then
MsgBox "密码不能为空!", vbOKCancel + vbInformation, "警告!"
Text2.Text = ""
Text2.SetFocus
Text3.Text = ""
Else
'添加新记录
mrc.AddNew
mrc.Fields(0) = Text1.Text
mrc.Fields(1) = Text2.Text
'更新数据库
mrc.Update
'关闭数据集
mrc.Close
Me.Hide
MsgBox "添加用户成功!", vbOKCancel + vbInformation, "添加用户成功!"
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -