📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form frmadduser
BackColor = &H00FFFFFF&
Caption = "添加新用户"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
FillColor = &H000000FF&
ForeColor = &H8000000C&
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 2 '屏幕中心
Begin VB.Data data1
Caption = "data1"
Connect = "Access"
DatabaseName = ""
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 375
Left = 960
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 2520
Visible = 0 'False
Width = 2295
End
Begin VB.CommandButton cmdcancel
Caption = "取消"
Height = 375
Left = 2400
TabIndex = 7
Top = 2040
Width = 1095
End
Begin VB.CommandButton cmdok
Caption = "添加"
Height = 375
Left = 720
TabIndex = 6
Top = 2040
Width = 1215
End
Begin VB.TextBox txtcode2
BeginProperty Font
Name = "MS Sans Serif"
Size = 13.5
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
IMEMode = 3 'DISABLE
Left = 1560
PasswordChar = "*"
TabIndex = 5
Top = 1440
Width = 2175
End
Begin VB.TextBox txtcode
BeginProperty Font
Name = "MS Sans Serif"
Size = 13.5
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
IMEMode = 3 'DISABLE
Left = 1560
PasswordChar = "*"
TabIndex = 4
Top = 720
Width = 2175
End
Begin VB.TextBox txtname
BeginProperty Font
Name = "MS Sans Serif"
Size = 13.5
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1680
TabIndex = 3
Top = 120
Width = 2055
End
Begin VB.Label Label3
Caption = "请再次输入密码"
Height = 255
Left = 120
TabIndex = 2
Top = 1560
Width = 1455
End
Begin VB.Label Label2
Caption = "请输入用户密码"
Height = 375
Left = 120
TabIndex = 1
Top = 840
Width = 1335
End
Begin VB.Label Label1
Caption = "请输入用户名"
Height = 375
Left = 240
TabIndex = 0
Top = 240
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 cmdcancel_Click()
Unload frmadduser
End Sub
Private Sub cmdok_Click()
'Dim str As String
'判断您是否具有添加用户的权限
If flag = 2 Then
MsgBox "非法操作!退出操作!!"
Unload frmadduser
Exit Sub
End If
'检查用户名和密码不为空,以及两次输入的密码是否一致
If txtname.Text = "" Then
MsgBox "用户名不能为空,请重输!!!"
txtcode.Text = ""
txtcode2.Text = ""
txtname.SetFocus
Exit Sub
End If
If txtcode.Text = "" Then
MsgBox "密码不能为空,请重新输入!!!"
txtcode.Text = ""
txtcode2.Text = ""
txtcode.SetFocus
Exit Sub
End If
If txtcode.Text <> txtcode2.Text Then
MsgBox "两次输入的密码不一致,请重输!!"
txtcode.Text = ""
txtcode2.Text = ""
txtcode.SetFocus
Exit Sub
End If
data1.Connect = "Access"
data1.DatabaseName = "" & App.Path & "\db1.mdb"
data1.RecordSource = "select *from user"
data1.Refresh
'判断输入的用户是否已存在
data1.Recordset.MoveFirst
While data1.Recordset.Fields("User_Name").Value <> txtname
data1.Recordset.MoveNext
If data1.Recordset.EOF Then
GoTo C
End If
Wend
If data1.Recordset.Fields("User_Name") = txtname Then
MsgBox "该用户已经存在,请重新输入!!!"
txtname.Text = ""
txtcode.Text = ""
txtcode2.Text = ""
txtname.SetFocus
Exit Sub
End If
C: data1.Recordset.AddNew
data1.Recordset.Fields("User_Name").Value = txtname.Text
data1.Recordset.Fields("User_Password").Value = txtcode.Text
data1.Recordset.Update
MsgBox "添加系统用户成功!!!"
txtname.Text = ""
txtcode.Text = ""
txtcode2.Text = ""
txtname.SetFocus
End Sub
Private Sub Form_Load()
If flag = 2 Then
Label1.ToolTipText = "无权添加!"
txtname.ToolTipText = "无权添加!"
End If
End Sub
Private Sub txtcode_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtcode2.SetFocus
End If
End Sub
Private Sub txtcode2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call cmdok_Click
End If
End Sub
Private Sub txtname_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtcode.SetFocus
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -