📄 frmadduser.frm
字号:
VERSION 5.00
Begin VB.Form frmadduser
BorderStyle = 1 'Fixed Single
Caption = "添加用户"
ClientHeight = 3195
ClientLeft = 45
ClientTop = 330
ClientWidth = 4680
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton cmdcanel
Caption = "取 消"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2400
TabIndex = 7
Top = 2280
Width = 1455
End
Begin VB.CommandButton cmdOK
Caption = "确 定"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 480
TabIndex = 6
Top = 2280
Width = 1455
End
Begin VB.TextBox txtpassword2
Height = 375
IMEMode = 3 'DISABLE
Left = 1560
PasswordChar = "*"
TabIndex = 5
Top = 1440
Width = 2175
End
Begin VB.TextBox txtpassword1
Height = 375
IMEMode = 3 'DISABLE
Left = 1560
PasswordChar = "*"
TabIndex = 4
Top = 960
Width = 2175
End
Begin VB.TextBox txtusername
Height = 375
Left = 1560
TabIndex = 3
Top = 480
Width = 2175
End
Begin VB.Label Label3
Alignment = 2 'Center
Caption = "请确认密码"
BeginProperty Font
Name = "新宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 2
Top = 1560
Width = 1215
End
Begin VB.Label Label2
Alignment = 2 'Center
Caption = "请输入密码"
BeginProperty Font
Name = "新宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 1
Top = 1080
Width = 1215
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "请输入用户名"
BeginProperty Font
Name = "新宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 0
Top = 600
Width = 1215
End
End
Attribute VB_Name = "frmadduser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdcanel_Click()
Unload Me
End Sub
Private Sub cmdok_Click()
Dim txtsql As String '用于存放SQL命令
Dim mrc As ADODB.Recordset '返回记录集
'Dim cnn1 As ADODB.Recordset
Dim msgtext As String
If Trim(txtusername.Text) = "" Then '判断是否输入用户名
MsgBox "用户名不能为空,请输入用户名!", vbOKOnly + vbExclamation, "警告"
Exit Sub
txtusername.SetFocus
Else
txtsql = "select * from users" '查找数据库中的信息
Set mrc = ExecuteSQL(txtsql, msgtext) '返回记录集
While (mrc.EOF = False) '从记录集中判断用户名是否存在
If Trim(mrc.Fields(0)) = Trim(txtusername.Text) Then
MsgBox "用户名已经存在,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtusername.SetFocus
txtusername.Text = ""
txtpassword1.Text = ""
txtpassword2.Text = ""
Exit Sub
Else
mrc.MoveNext '核对下一条记录
End If
Wend
'mrc.Close
End If
If Trim(txtpassword1.Text) <> Trim(txtpassword2.Text) Then '判断用户两次输入密码是否一致
MsgBox "两次密码输入不一致", vbOKOnly + vbExclamation, "警告"
txtusername.SetFocus
txtusername.Text = ""
txtpassword1.Text = ""
txtpassword2.Text = ""
Else
If txtpassword1.Text = "" Then '判断密码是否为空
MsgBox "密码不能为空", vbOKOnly + vbExclamation, "警告"
txtusername.SetFocus
txtusername.Text = ""
txtpassword1.Text = ""
txtpassword2.Text = ""
Else
'mrc.Update
txtsql = "select * from users" '查找数据库中的信息
Set mrc = ExecuteSQL(txtsql, msgtext)
'mrc.Update
mrc.AddNew '添加新记录
'mrc!user_id = Trim(txtusername.Text)
'mrc!user_pwd = Trim(txtpassword1.Text)
mrc.Fields(0) = Trim(txtusername.Text) '字段赋值
mrc.Fields(1) = Trim(txtpassword1.Text)
mrc.Update '更新数据库
mrc.Close
Me.Hide
MsgBox "添加用户成功", vbOKOnly + vbExclamation, "添加用户"
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -