📄 register.frm
字号:
VERSION 5.00
Begin VB.Form Register
BackColor = &H8000000A&
Caption = "注册"
ClientHeight = 4815
ClientLeft = 60
ClientTop = 345
ClientWidth = 4845
LinkTopic = "Form1"
ScaleHeight = 4815
ScaleWidth = 4845
StartUpPosition = 3 '窗口缺省
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = "userInformation.mdb"
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 285
Left = 120
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "用户信息"
Top = 4440
Visible = 0 'False
Width = 4575
End
Begin VB.CommandButton Command2
Caption = "返回"
Height = 495
Left = 3360
TabIndex = 8
Top = 3840
Width = 855
End
Begin VB.CommandButton Command1
Caption = "提交"
Default = -1 'True
Height = 495
Left = 2280
TabIndex = 7
Top = 3870
Width = 855
End
Begin VB.Frame Frame1
BackColor = &H8000000A&
Caption = "注册新用户"
Height = 3735
Left = 480
TabIndex = 9
Top = 120
Width = 4215
Begin VB.TextBox Text7
Height = 375
Left = 1440
TabIndex = 6
Top = 3120
Width = 1455
End
Begin VB.TextBox Text6
Height = 375
Left = 1440
MaxLength = 18
TabIndex = 5
Top = 2640
Width = 1455
End
Begin VB.TextBox Text5
Height = 375
Left = 1440
TabIndex = 4
Top = 2160
Width = 1455
End
Begin VB.TextBox Text4
Height = 375
Left = 1440
TabIndex = 3
Top = 1680
Width = 1455
End
Begin VB.TextBox Text3
Height = 375
IMEMode = 3 'DISABLE
Left = 1440
PasswordChar = "*"
TabIndex = 2
Top = 1200
Width = 1455
End
Begin VB.TextBox Text2
Height = 375
IMEMode = 3 'DISABLE
Left = 1440
PasswordChar = "*"
TabIndex = 1
Top = 720
Width = 1455
End
Begin VB.TextBox Text1
Height = 375
Left = 1440
TabIndex = 0
Top = 240
Width = 1455
End
Begin VB.Label Label9
BackStyle = 0 'Transparent
Caption = "(15位或18位)"
Height = 255
Left = 3000
TabIndex = 18
Top = 2760
Width = 1095
End
Begin VB.Label Label8
BackStyle = 0 'Transparent
Caption = "(密码不允许超过10位)"
Height = 375
Left = 3000
TabIndex = 17
Top = 720
Width = 1095
End
Begin VB.Label Label7
BackStyle = 0 'Transparent
Caption = "E-mail"
Height = 255
Left = 240
TabIndex = 16
Top = 3240
Width = 615
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "身份证号"
Height = 255
Left = 240
TabIndex = 15
Top = 2760
Width = 855
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "回答问题"
Height = 255
Left = 240
TabIndex = 14
Top = 2280
Width = 855
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "提示问题"
Height = 255
Left = 240
TabIndex = 13
Top = 1800
Width = 855
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "确认密码"
Height = 255
Left = 240
TabIndex = 12
Top = 1320
Width = 855
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "输入密码"
Height = 255
Left = 240
TabIndex = 11
Top = 840
Width = 855
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "用户名"
Height = 255
Left = 240
TabIndex = 10
Top = 360
Width = 735
End
End
End
Attribute VB_Name = "Register"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim password As String, repassword As String
Private Sub Command1_Click()
Data1.RecordSource = "用户信息"
Data1.Recordset.AddNew
Data1.Recordset.Fields("用户名") = Text1.Text
Data1.Recordset.Fields("输入密码") = Text2.Text
Data1.Recordset.Fields("确认密码") = Text3.Text
Data1.Recordset.Fields("提示问题") = Text4.Text
Data1.Recordset.Fields("回答问题") = Text5.Text
Data1.Recordset.Fields("身份证号") = Text6.Text
Data1.Recordset.Fields("E-mail") = Text7.Text
Data1.Recordset.Update
Text1.Text = "": Text2.Text = "": Text3.Text = ""
Text4.Text = "": Text5.Text = "": Text6.Text = "": Text7.Text = ""
pass.Show
Me.Hide
End Sub
Private Sub Command2_Click()
Text1.Text = "": Text2.Text = "": Text3.Text = "": Text4.Text = ""
Text5.Text = "": Text6.Text = "": Text7.Text = ""
Me.Hide
pass.Show
End Sub
Private Sub Form_Load()
Text2.SelLength = 0
Text3.SelLength = 0
Text6.SelLength = 0
End Sub
Private Sub Text1_LostFocus()
Dim username As String
username = Trim(Text1.Text)
If Text1.Text <> "" Then
Data1.RecordSource = "Select * From 用户信息 Where 用户名 ='" & username & "'"
Data1.Refresh
If Data1.Recordset.EOF Then
Text2.SetFocus
Else
MsgBox "对不起,已存在此用户!请更换一个用户名!", vbOKOnly + vbExclamation, "警告"
Text1.Text = ""
Text1.SetFocus
End If
Else
Text1.SetFocus
End If
Data1.RecordSource = "用户信息"
Data1.Refresh
End Sub
Private Sub Text2_LostFocus()
password = Trim(Text2.Text)
If Text2.MaxLength > 10 Then
MsgBox "密码不允许超过10位", vbOKOnly + vbExclamation, "错误提示"
Text2.Text = ""
Text2.SetFocus
End If
End Sub
Private Sub Text3_LostFocus()
repassword = Trim(Text3.Text)
If Text3.MaxLength > 10 Or repassword <> password Then
MsgBox "你输入的密码超过了10位或两次输入的密码不一致,请重新再输!", vbOKOnly + vbExclamation, "错误提示"
Text3.Text = ""
Text3.SetFocus
End If
End Sub
Private Sub Text6_LostFocus()
If Not IsNumeric(Text6.Text) Then
MsgBox "身份证号应为数字字符!", vbOKOnly + vbExclamation, "错误提示"
Text6.Text = ""
Text6.SetFocus
Else
If (Len(Text6.Text) = 15) Or (Len(Text6.Text) = 18) Then
Text7.SetFocus
Else
MsgBox "你输入的不是身份证号吧!", vbOKOnly + vbExclamation, "错误提示"
Text6.Text = ""
Text6.SetFocus
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -