📄 form10.frm
字号:
VERSION 5.00
Begin VB.Form Form10
BorderStyle = 3 'Fixed Dialog
Caption = "添加用户"
ClientHeight = 3015
ClientLeft = 3285
ClientTop = 2775
ClientWidth = 4065
LinkTopic = "Form10"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 3015
ScaleWidth = 4065
ShowInTaskbar = 0 'False
Begin VB.Frame Frame1
Caption = "新用户注册"
Height = 2775
Left = 120
TabIndex = 0
Top = 120
Width = 3855
Begin VB.TextBox Text3
Height = 270
IMEMode = 3 'DISABLE
Left = 1560
PasswordChar = "*"
TabIndex = 8
Top = 1680
Width = 1695
End
Begin VB.TextBox Text2
Height = 270
IMEMode = 3 'DISABLE
Left = 1560
PasswordChar = "*"
TabIndex = 7
Top = 1080
Width = 1695
End
Begin VB.TextBox Text1
Height = 270
Left = 1560
TabIndex = 6
Top = 480
Width = 1695
End
Begin VB.CommandButton Command2
BackColor = &H00FF8080&
Caption = "取消"
Height = 375
Left = 2160
Style = 1 'Graphical
TabIndex = 5
Top = 2160
Width = 855
End
Begin VB.CommandButton Command1
BackColor = &H00FF8080&
Caption = "确定"
Height = 375
Left = 840
Style = 1 'Graphical
TabIndex = 4
Top = 2160
Width = 855
End
Begin VB.Label Label3
Caption = "确认密码:"
Height = 255
Left = 480
TabIndex = 3
Top = 1680
Width = 975
End
Begin VB.Label Label2
Caption = " 密码:"
Height = 255
Left = 480
TabIndex = 2
Top = 1080
Width = 975
End
Begin VB.Label Label1
Caption = "新用户名:"
Height = 255
Left = 480
TabIndex = 1
Top = 480
Width = 975
End
End
End
Attribute VB_Name = "Form10"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Conn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Private Sub Command1_Click()
Dim Txtsql As String
Dim Mrc As ADODB.Recordset
'Set Cmd.ActiveConnection = Conn
'检查输入用户名是否在数据库中有同名记录
If Trim(Text1.Text) = "" Then
MsgBox "请输入用户名称!", vbExclamation, "出错啦!"
Exit Sub
Else
Txtsql = "select * from 用户表"
'Cmd.CommandText = Txtsql
'Cmd.CommandType = adCmdText
'Set Mrc = Cmd.Execute
Set Mrc = ExecuteSQL(Txtsql)
While (Mrc.EOF = False)
If Trim(Mrc.Fields(0)) = Trim(Text1.Text) Then
MsgBox "用户已经存在,请重新输入!", , "出错啦!"
Exit Sub
Else
Mrc.MoveNext
End If
Wend
End If
'检查两次密码是否一致
If Trim(Text2.Text) <> Trim(Text3.Text) Then
MsgBox "两次输入的密码不一样,请确认!", , "出错啦!"
Exit Sub
Else
If Text2.Text = "" Then
MsgBox "密码不能为空!", vbExclamation, "出错啦!"
Exit Sub
Else
Rs.AddNew
Rs("用户名") = Trim(Text1.Text)
Rs("密码") = Trim(Text3.Text)
Me.Hide
Rs.Update
'Mrc.AddNew
'Mrc.Fields(0) = Trim(Text1.Text)
'Mrc.Fields(1) = Trim(Text3.Text)
'Mrc.Update
MsgBox "添加用户成功!", , "添加用户!"
End If
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
connstr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\学生信息管理.mdb"
Conn.Open connstr
Rs.Open "用户表", Conn, adOpenKeyset, adLockPessimistic
End Sub
Private Sub Form_Unload(Cancel As Integer)
Rs.Close
Conn.Close
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.SetFocus
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text3.SetFocus
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command1.SetFocus
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -