📄 tianjiayonghu.frm
字号:
VERSION 5.00
Begin VB.Form tianjiayonghu
Caption = "添加用户"
ClientHeight = 3165
ClientLeft = 60
ClientTop = 345
ClientWidth = 4590
LinkTopic = "Form1"
ScaleHeight = 3165
ScaleWidth = 4590
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame1
Height = 3135
Left = 0
TabIndex = 0
Top = 0
Width = 4575
Begin VB.TextBox Text4
Height = 375
IMEMode = 3 'DISABLE
Left = 1680
PasswordChar = "*"
TabIndex = 10
Top = 1800
Width = 2535
End
Begin VB.CommandButton Command2
Caption = "取消"
Height = 375
Left = 2880
TabIndex = 8
Top = 2400
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "确认"
Default = -1 'True
Height = 375
Left = 480
TabIndex = 7
Top = 2400
Width = 975
End
Begin VB.TextBox Text3
Height = 375
IMEMode = 3 'DISABLE
Left = 1680
PasswordChar = "*"
TabIndex = 6
Top = 1320
Width = 2535
End
Begin VB.TextBox Text2
Height = 375
Left = 1680
TabIndex = 4
Top = 840
Width = 2535
End
Begin VB.TextBox Text1
Height = 375
Left = 1680
TabIndex = 2
Top = 360
Width = 2535
End
Begin VB.Label Label4
Caption = "请输入新密码:"
Height = 255
Left = 360
TabIndex = 9
Top = 1320
Width = 1215
End
Begin VB.Label Label3
Caption = "请确认密码:"
Height = 255
Left = 360
TabIndex = 5
Top = 1800
Width = 1095
End
Begin VB.Label Label2
Caption = "帐号:"
Height = 255
Left = 360
TabIndex = 3
Top = 840
Width = 1095
End
Begin VB.Label Label1
Caption = "请输入用户名:"
Height = 255
Left = 360
TabIndex = 1
Top = 360
Width = 1215
End
End
End
Attribute VB_Name = "tianjiayonghu"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim db As Database '定义对象变量
Dim rs As Recordset '将定义的对象赋给对象变量
Dim a As String
On Error Resume Next 'OPTION EXPLICIT是用来规定酥油变量使用前必须定义.这样可以避免由于输入错误而产生的新变量
Set db = OpenDatabase(App.Path & "\登陆信息表") '打开数据库
Set rs = db.OpenRecordset("登陆信息表") '构成记录集
While (rs.EOF = False)
If rs.Fields(0) = Text2.Text Then '判断用户名字是否已经存在
MsgBox "用户已经存在!", vbOKOnly + vbExclamation, "警告!"
Text1.SetFocus '如果用户已经存在了输入框清空
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Exit Sub
Else
rs.MoveNext '移动到下一条记录
End If
Wend '对应WHILE
If Text3.Text <> Text4.Text Then
MsgBox "两次输入的密码不一样,请重新输入!", vbOKOnly + vbExclamation, "jinggao"
Text3.SetFocus
Text3.Text = ""
Text4.Text = ""
Else
rs.AddNew
'添加新用户
rs.Fields(0) = Text2.Text '添加帐号
rs.Fields(1) = Text3.Text '添加用户密码
rs.Fields(2) = Text1.Text '添加用户名字
rs.Update '更新数据库
tianjiayonghu.Hide
MsgBox "添加用户成功!", vbOKOnly + vbExclamation, "add the user!"
rs.Close '关闭记录集
Text1.Text = "" '把输入框清空
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End If
End Sub
Private Sub Command2_Click()
tianjiayonghu.Hide
jiudianneibuziliaocaidan.Show
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -