📄 frmadduser.frm
字号:
VERSION 5.00
Begin VB.Form frmadduser
Caption = "设定用户"
ClientHeight = 2940
ClientLeft = 60
ClientTop = 450
ClientWidth = 4770
LinkTopic = "Form1"
ScaleHeight = 2940
ScaleWidth = 4770
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command2
Caption = "取消"
Height = 375
Left = 2400
TabIndex = 7
Top = 2040
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 375
Left = 600
TabIndex = 6
Top = 2040
Width = 1335
End
Begin VB.TextBox Text3
Height = 375
IMEMode = 3 'DISABLE
Left = 1680
PasswordChar = "*"
TabIndex = 5
Top = 1200
Width = 2535
End
Begin VB.TextBox Text2
Height = 375
IMEMode = 3 'DISABLE
Left = 1680
PasswordChar = "*"
TabIndex = 4
Top = 720
Width = 2535
End
Begin VB.TextBox Text1
Height = 375
Left = 1680
TabIndex = 3
Top = 240
Width = 2535
End
Begin VB.Label Label3
Caption = "确认密码:"
Height = 255
Left = 240
TabIndex = 2
Top = 1320
Width = 1095
End
Begin VB.Label Label2
Caption = "输入密码:"
Height = 255
Left = 240
TabIndex = 1
Top = 840
Width = 1095
End
Begin VB.Label Label1
Caption = "输入用户名:"
Height = 255
Left = 240
TabIndex = 0
Top = 360
Width = 1095
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()
Dim sql As String
Dim rs_add As New ADODB.Recordset
Dim conn As New ADODB.Connection
conn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\database.mdb"
If Trim(Text1.Text) = "" Then
MsgBox "用户名不能为空,请输入!", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Else
sql = "select * from 用户表"
rs_add.Open sql, conn, adOpenKeyset, adLockPessimistic
While (rs_add.EOF = False)
If Trim(rs_add.Fields(0)) = Trim(Text1.Text) Then
MsgBox "已有这个用户", vbOKOnly + vbExclamation, ""
Text1.SetFocus
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Exit Sub
Else
rs_add.MoveNext
End If
Wend
If Trim(Text2.Text) <> Trim(Text3.Text) Then
MsgBox "两次密码不一致", vbOKOnly + vbExclamation, ""
Text2.SetFocus
Text2.Text = ""
Text3.Text = ""
Exit Sub
Else
rs_add.AddNew
rs_add.Fields(0) = Text1.Text
rs_add.Fields(1) = Text2.Text
rs_add.Update
MsgBox "添加用户成功!", vbOKOnly + vbExclamation, ""
Me.Hide
End If
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -