📄 添加用户.frm
字号:
VERSION 5.00
Begin VB.Form frmadduser
BackColor = &H00C0E0FF&
Caption = "添加/删除 用户"
ClientHeight = 5475
ClientLeft = 4260
ClientTop = 3450
ClientWidth = 6510
LinkTopic = "Form4"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5475
ScaleWidth = 6510
Begin VB.CommandButton Command3
Caption = "删除"
Height = 375
Left = 2640
TabIndex = 8
Top = 4440
Width = 855
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 375
Left = 4080
TabIndex = 7
Top = 4440
Width = 855
End
Begin VB.TextBox Text3
Height = 375
IMEMode = 3 'DISABLE
Left = 2880
PasswordChar = "*"
TabIndex = 3
Top = 3120
Width = 1455
End
Begin VB.TextBox Text2
Height = 375
IMEMode = 3 'DISABLE
Left = 2880
PasswordChar = "*"
TabIndex = 2
Top = 2280
Width = 1455
End
Begin VB.TextBox Text1
Height = 375
Left = 2880
TabIndex = 1
Top = 1440
Width = 1455
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 375
Left = 1200
TabIndex = 0
Top = 4440
Width = 855
End
Begin VB.Label Label3
BackColor = &H00C0E0FF&
Caption = "确认"
Height = 255
Left = 1680
TabIndex = 6
Top = 3120
Width = 495
End
Begin VB.Label Label2
BackColor = &H00C0E0FF&
Caption = "口令"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 1680
TabIndex = 5
Top = 2280
Width = 495
End
Begin VB.Label Label1
BackColor = &H00C0E0FF&
Caption = "用户名"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 1560
TabIndex = 4
Top = 1560
Width = 735
End
End
Attribute VB_Name = "frmadduser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
dcpath = "c:\点菜系统.mdb"
Set dcdb = OpenDatabase(dcpath)
Set superuser = dcdb.OpenRecordset("超级用户", dbOpenTable)
If Text1.Text = "" Then
MsgBox "用户名不能为空!"
Text1.Text = ""
Text1.SetFocus
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "用户口令不能为空!"
Text2.SetFocus
Exit Sub
End If
If Text2.Text <> Text3.Text Then
MsgBox "两次输入的口令不一致!"
Text3.Text = ""
Text3.SetFocus
Exit Sub
End If
superuser.MoveFirst
While Not superuser.EOF
If superuser.Fields(0) = Text1.Text Then
MsgBox "此用户已存在!"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
Exit Sub
End If
superuser.MoveNext
Wend
superuser.MoveLast
superuser.AddNew
superuser.Fields(0) = Text1.Text
superuser.Fields(1) = Text2.Text
superuser.Update
MsgBox "新用户已成功添加!"
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
superuser.MoveFirst
While Not superuser.EOF
If superuser.Fields(0) = Text1.Text Then
superuser.Delete
MsgBox "此用户被成功删除!"
Exit Sub
End If
superuser.MoveNext
Wend
MsgBox "无此用户!"
Text1.Text = ""
Text1.SetFocus
End Sub
Private Sub Form_Load()
Form1.Enabled = False
dcpath = "c:\点菜系统.mdb"
Set dcdb = OpenDatabase(dcpath)
Set superuser = dcdb.OpenRecordset("超级用户", dbOpenTable)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Form1.Enabled = True
dcdb.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -