📄 formreg.frm
字号:
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim I As Integer
Dim s As Integer
Dim SQL As String
Dim c1 As New Class1
Dim PwMD5 As String
Dim x As Integer
Dim pw1 As String
Dim pw2 As String
Dim pas As String
Dim ec As Integer
Dim Sec As Integer
Private Sub Combo1_Click()
Label4.Caption = Combo1.Text
Option5.Visible = True
Label5.Visible = True
Option6.Visible = True
Label6.Visible = True
Option5.value = True
Call Option5_Click
End Sub
Private Sub Command1_Click()
DataEnvironment1.Commands(2).CommandType = adCmdText
SQL = "select * from usr where name='" & Label1.Caption & "'"
DataEnvironment1.rsCommand2.Open SQL
If DataEnvironment1.Recordsets(2).EOF Then
Label2.Visible = True
Option2.Visible = True
Text1.Visible = True
Command1.Visible = False
Label10.Visible = False
Option2.value = True
Call Option2_Click
DataEnvironment1.Recordsets(2).Close
Option2.Visible = True
Label2.Visible = True
Option3.Visible = True
Label3.Visible = True
Else
Label10.Visible = True
Label10.Caption = "用户名已存在"
Command1.Enabled = False
Text1.Visible = True
Text1.SetFocus
DataEnvironment1.Recordsets(2).Close
End If
End Sub
Private Sub Command2_Click()
I = 9
Label9.Caption = "用 户 注 册 " & I & "/9"
Option1.Visible = False
Option2.Visible = False
Option3.Visible = False
Option4.Visible = False
Option5.Visible = False
Option6.Visible = False
Option7.Visible = False
Option8.Visible = False
Label1.Visible = False
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
Label5.Visible = False
Label6.Visible = False
Label7.Visible = False
Label8.Visible = False
Text1.Visible = False
Combo1.Visible = False
Label11.Visible = True
Command2.Visible = False
Timer1.Enabled = True
Call Timer1_Timer
End Sub
Private Sub Command3_Click()
Option1.Visible = False
Option2.Visible = False
Option3.Visible = False
Option4.Visible = False
Option5.Visible = False
Option6.Visible = False
Option7.Visible = False
Option8.Visible = False
Label1.Visible = False
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
Label5.Visible = False
Label6.Visible = False
Label7.Visible = False
Label8.Visible = False
Label9.Visible = True
Label9.Caption = "返 回 操 作"
Label10.Visible = False
Label11.Visible = True
Combo1.Visible = False
Text1.Visible = False
Command1.Visible = False
Command2.Visible = False
Command3.Visible = False
Sec = 0
Timer2.Enabled = True
Call Timer2_Timer
End Sub
Private Sub Form_Load()
Sec = 0
End Sub
Private Sub Option1_Click()
I = 1
Label9.Caption = "用 户 注 册 " & I & "/9"
Text1.Visible = True
Combo1.Visible = False
Text1.PasswordChar = ""
Text1.Text = Label1.Caption
Text1.SetFocus
Text1.SelStart = 0
s = Len(Text1.Text)
Text1.SelLength = s
End Sub
Private Sub Option2_Click()
I = 2
Label9.Caption = "用 户 注 册 " & I & "/9"
Text1.Visible = True
Combo1.Visible = False
Text1.PasswordChar = "*"
Text1.Text = ""
Text1.SetFocus
End Sub
Private Sub Option3_Click()
I = 3
Label9.Caption = "用 户 注 册 " & I & "/9"
Text1.Visible = True
Combo1.Visible = False
Text1.PasswordChar = "*"
Text1.Text = ""
Text1.SetFocus
End Sub
Private Sub Option4_Click()
I = 4
Label9.Caption = "用 户 注 册 " & I & "/9"
Text1.Visible = False
Combo1.Visible = True
Combo1.SetFocus
End Sub
Private Sub Option5_Click()
I = 5
Label9.Caption = "用 户 注 册 " & I & "/9"
Text1.Visible = True
Combo1.Visible = False
Text1.PasswordChar = ""
Text1.Text = Label5.Caption
Text1.SetFocus
Text1.SelStart = 0
s = Len(Text1.Text)
Text1.SelLength = s
End Sub
Private Sub Option6_Click()
I = 6
Label9.Caption = "用 户 注 册 " & I & "/9"
Text1.Visible = True
Combo1.Visible = False
Text1.PasswordChar = ""
Text1.Text = ""
Text1.SetFocus
End Sub
Private Sub Option7_Click()
I = 7
Label9.Caption = "用 户 注 册 " & I & "/9"
Text1.Visible = True
Combo1.Visible = False
Text1.PasswordChar = ""
Text1.Text = Label7.Caption
Text1.SetFocus
Text1.SelStart = 0
s = Len(Text1.Text)
Text1.SelLength = s
End Sub
Private Sub Option8_Click()
I = 8
Label9.Caption = "用 户 注 册 " & I & "/9"
Text1.Visible = True
Combo1.Visible = False
Text1.PasswordChar = ""
Text1.Text = Label8.Caption
Text1.SetFocus
Text1.SelStart = 0
s = Len(Text1.Text)
Text1.SelLength = s
End Sub
Private Sub Text1_Change()
If Command1.Enabled = False Then Command1.Enabled = True
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Select Case I
Case 1
Label1.Caption = Text1.Text
Text1.Text = ""
Text1.Visible = False
Command1.Visible = True
Command1.SetFocus
Case 2
If Len(Text1.Text) >= 6 Then
pw1 = c1.DigestStrToHexStr(Text1.Text)
Label2.Caption = "密码已记录"
Label3.Caption = ""
Option3.value = True
Call Option3_Click
Call Check
Else
Label2.Caption = "至少6位"
Text1.Text = ""
End If
Case 3
pw2 = c1.DigestStrToHexStr(Text1.Text)
Text1.Text = ""
If pw1 = pw2 Then
Label3.Caption = "密码验证成功"
PwMD5 = pw1
Option4.Visible = True
Label4.Visible = True
Option4.value = True
Call Option4_Click
Call Check
Else
Label2.Caption = "密码不一致"
Label3.Caption = "请重新输入"
Option2.value = True
Call Option2_Click
End If
Case 5
Label5.Caption = Text1.Text
Text1.Text = ""
Option6.value = True
Call Option6_Click
Call Check
Case 6
pas = c1.DigestStrToHexStr(Text1.Text)
Label6.Caption = "答案已记录"
Text1.Text = ""
Option7.Visible = True
Label7.Visible = True
Option7.value = True
Call Option7_Click
Call Check
Case 7
Label7.Caption = Text1.Text
Text1.Text = ""
Option8.Visible = True
Label8.Visible = True
Option8.value = True
Call Option8_Click
Call Check
Case 8
Call CheckEmail
End Select
End If
End Sub
Private Sub Check()
If Label1.Caption <> "" Then
If Label2.Caption <> "密码不一致" Then
If Label3.Caption <> "请重新输入" Then
If Label4.Caption <> "" Then
If Label5.Caption <> "" Then
If Label6.Caption <> "" Then
If Label7.Caption <> "" Then
If Label8.Caption <> "" Then
Command2.Visible = True
Command2.SetFocus
End If
End If
End If
End If
End If
End If
End If
End If
End Sub
Private Sub CheckEmail()
ec = 0
s = Len(Text1.Text)
For x = 1 To s - 1
If Mid(Text1.Text, x, 1) = "@" Then ec = ec + 1
Next x
If ec = 1 Then
Label8.Caption = Text1.Text
Text1.Text = ""
Call Check
Else
MsgBox "您输入的电子邮件格式错误!"
Text1.Visible = True
Combo1.Visible = False
Text1.PasswordChar = ""
Text1.SetFocus
Text1.SelStart = 0
s = Len(Text1.Text)
Text1.SelLength = s
End If
End Sub
Private Sub Timer1_Timer()
Sec = Sec + 1
Select Case Sec
Case 1
Label11.Caption = "连接数据库"
DataEnvironment1.Commands(2).CommandType = adCmdText
SQL = "insert into usr ([name],[password],[sex],[ques],[ans],[address],[mail],[right]) values ('" & Label1.Caption & "','" & PwMD5 & "','" & Label4.Caption & "','" & Label5.Caption & "','" & pas & "','" & Label7.Caption & "','" & Label8.Caption & "','O')"
DataEnvironment1.rsCommand2.Open SQL
UserName = Label1.Caption
QuanXian = "O"
Case 2
Label11.Caption = "注册成功,请记住你的注册信息"
Case 3
Label11.Caption = 6 - Sec & "秒后进入系统"
Case 4
Label11.Caption = 6 - Sec & "秒后进入系统"
Case 5
Label11.Caption = 6 - Sec & "秒后进入系统"
Case 6
Unload Me
FormIndex.Show
If DataEnvironment1.Commands(2).State <> adStateClosed Then DataEnvironment1.Recordsets(2).Close
End Select
End Sub
Private Sub Timer2_Timer()
Label11.Caption = 3 - Sec & " 秒返回登录"
If Sec = 3 Then
Unload Me
Formlogin.Show
End If
Sec = Sec + 1
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -