📄 adduser.frm
字号:
VERSION 5.00
Begin VB.Form Form10
BackColor = &H00FFC0C0&
BorderStyle = 1 'Fixed Single
Caption = "添加用户"
ClientHeight = 2805
ClientLeft = 3885
ClientTop = 1755
ClientWidth = 4155
Icon = "Adduser.frx":0000
LinkTopic = "Form10"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2805
ScaleWidth = 4155
Begin VB.CommandButton Command2
BackColor = &H00FFC0C0&
Caption = "取 消"
Height = 375
Left = 2640
Style = 1 'Graphical
TabIndex = 7
Top = 2160
Width = 1095
End
Begin VB.CommandButton Command1
BackColor = &H00FFC0C0&
Caption = "确 认"
Height = 375
Left = 360
MaskColor = &H00FFC0C0&
Style = 1 'Graphical
TabIndex = 6
Top = 2160
Width = 1095
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
IMEMode = 3 'DISABLE
Index = 2
Left = 1680
PasswordChar = "*"
TabIndex = 5
Top = 1440
Width = 1695
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
IMEMode = 3 'DISABLE
Index = 1
Left = 1680
PasswordChar = "*"
TabIndex = 3
Top = 840
Width = 1695
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Index = 0
Left = 1680
TabIndex = 1
Top = 240
Width = 1695
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "请确认密码:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 2
Left = 120
TabIndex = 4
Top = 1440
Width = 1335
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "请输入密码:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 1
Left = 120
TabIndex = 2
Top = 840
Width = 1335
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "请输入用户名:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 0
Left = 120
TabIndex = 0
Top = 240
Width = 1575
End
End
Attribute VB_Name = "Form10"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "RVB_UniqueId" ,"41FF01ED00CF"
Attribute VB_Ext_KEY = "RVB_ModelStereotype" ,"Form"
Private Sub Command1_Click()
Dim txtSQL As String
Dim mrc As ADODB.Recordset
Dim MsgText As String
'判断输入用户名是否为空
If Trim(Text1(0).Text = "") Then
MsgBox "请输入用户名!", vbOKOnly + vbExclamation, "警告"
Text1(0).SetFocus
Exit Sub
Else
txtSQL = "select * from User_info "
Set mrc = ExecuteSQL(txtSQL, MsgText)
'判断数据集是否为空
While (Not mrc.EOF)
If Trim(mrc.Fields(0)) = Trim(Text1(0).Text) Then
MsgBox "用户名已存在,请重新输入用户名!", vbOKOnly + vbExclamation, "注意"
Text1(0).SetFocus
Text1(0).Text = ""
Text1(1).Text = ""
Text1(2).Text = ""
mrc.Close
Exit Sub
Else
mrc.MoveNext
End If
Wend
End If
'判断两次输入密码是否一致
If Trim(Text1(1).Text) <> Trim(Text1(2).Text) Then
MsgBox "两次输入的密码不同,请重新输入!", vbOKOnly + vbExclamation, "警告"
Text1(1).SetFocus
Text1(1).Text = ""
Text1(2).Text = ""
mrc.Close
Exit Sub
Else '判断输入密码是否为空
If Trim(Text1(1).Text = "") Then
MsgBox "密码不能为空!", vbOKOnly + vbExclamation, "警告"
Text1(1).SetFocus
Text1(1).Text = ""
Text1(2).Text = ""
mrc.Close
Exit Sub
Else '添加新用户
mrc.AddNew
mrc.Fields(0) = Trim(Text1(0).Text)
mrc.Fields(1) = Trim(Text1(1).Text)
mrc.Update '更新数据库
MsgBox "用户添加成功!", vbOKOnly + vbExclamation, "添加用户"
mrc.Close
Me.Hide
End If
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If Index = 2 Then
If KeyCode = 13 Then
Call Command1_Click
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -