?? register.frm
字號:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form Register
Caption = "注冊為用戶"
ClientHeight = 5400
ClientLeft = 60
ClientTop = 345
ClientWidth = 5685
Icon = "Register.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
ScaleHeight = 5400
ScaleWidth = 5685
Begin VB.Frame FrameReg
Height = 4815
Left = 360
TabIndex = 1
Top = 360
Width = 4815
Begin VB.CommandButton cmdReg
Caption = "注冊"
Default = -1 'True
Height = 495
Left = 240
TabIndex = 15
Top = 4080
Width = 4215
End
Begin VB.TextBox txtUnit
Height = 855
Left = 1200
MaxLength = 50
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 14
Top = 2880
Width = 3015
End
Begin MSComCtl2.UpDown udAge
Height = 270
Left = 1666
TabIndex = 12
Top = 2272
Width = 270
_ExtentX = 423
_ExtentY = 476
_Version = 393216
Value = 21
AutoBuddy = -1 'True
BuddyControl = "txtAge"
BuddyDispid = 196612
OrigLeft = 1680
OrigTop = 2280
OrigRight = 1950
OrigBottom = 2535
Max = 150
Min = 1
SyncBuddy = -1 'True
BuddyProperty = 65547
Enabled = -1 'True
End
Begin VB.TextBox txtAge
Height = 270
Left = 1200
MaxLength = 3
TabIndex = 11
Top = 2272
Width = 465
End
Begin VB.TextBox txtRealname
Height = 270
Left = 1200
MaxLength = 10
TabIndex = 9
Top = 1800
Width = 3015
End
Begin VB.TextBox txtPwAgain
Height = 270
IMEMode = 3 'DISABLE
Left = 1200
MaxLength = 20
PasswordChar = "*"
TabIndex = 7
Top = 1320
Width = 3015
End
Begin VB.TextBox txtPassword
Height = 270
IMEMode = 3 'DISABLE
Left = 1200
MaxLength = 20
PasswordChar = "*"
TabIndex = 5
Top = 840
Width = 3015
End
Begin VB.TextBox txtUserName
Height = 270
Left = 1200
MaxLength = 20
TabIndex = 3
Top = 360
Width = 3015
End
Begin VB.Label Label8
Caption = "*"
Height = 255
Index = 2
Left = 4320
TabIndex = 18
Top = 1320
Width = 255
End
Begin VB.Label Label8
Caption = "*"
Height = 255
Index = 1
Left = 4320
TabIndex = 17
Top = 840
Width = 255
End
Begin VB.Label Label8
Caption = "*"
Height = 255
Index = 0
Left = 4320
TabIndex = 16
Top = 360
Width = 255
End
Begin VB.Label Label7
Caption = "班級:"
Height = 255
Left = 240
TabIndex = 13
Top = 2880
Width = 735
End
Begin VB.Label Label6
Caption = "年齡:"
Height = 255
Left = 240
TabIndex = 10
Top = 2280
Width = 615
End
Begin VB.Label Label5
Caption = "真實姓名:"
Height = 255
Left = 240
TabIndex = 8
Top = 1815
Width = 1095
End
Begin VB.Label Label4
Caption = "密碼確認:"
Height = 255
Left = 240
TabIndex = 6
Top = 1335
Width = 975
End
Begin VB.Label Label3
Caption = "密碼:"
Height = 255
Left = 240
TabIndex = 4
Top = 855
Width = 735
End
Begin VB.Label Label2
Caption = "用戶名:"
Height = 255
Left = 240
TabIndex = 2
Top = 375
Width = 975
End
End
Begin VB.Label Label1
Caption = "歡迎注冊成為新用戶!(打*號為必添項)"
ForeColor = &H00FF0000&
Height = 255
Left = 360
TabIndex = 0
Top = 120
Width = 4935
End
End
Attribute VB_Name = "Register"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdReg_Click()
'Dim cmd As Command
Usertype = General
State = 1
Set cmd = New Command
DataE.Connections("conLibrary").Open
cmd.ActiveConnection = DataE.Connections("conLibrary")
cmd.CommandText = "insert into UserTable(UserName,RealName,Unit,pwd,RegisterTime,age,state,usertype) values('" & txtUserName.Text & "','" & txtRealname.Text & "','" & txtUnit.Text & "','" & txtPassword.Text & "','" & Now & "','" & udAge.Value & "','" & State & "','" & Usertype & "')"
cmd.CommandText = "select * from usertable where username='" & txtUserName & "'"
'子段不要使用關鍵字“PassWord”
'驗證重要信息已經填寫
If txtUserName.Text = "" Then
MsgBox "請填寫用戶名!", vbOKOnly + vbInformation, "注意"
txtUserName.SetFocus
Exit Sub
ElseIf txtPassword.Text = "" Then
MsgBox "請填寫密碼!", vbOKOnly + vbInformation, "注意"
txtPassword.SetFocus
Exit Sub
ElseIf txtPwAgain.Text = "" Then
MsgBox "請填寫確認密碼!", vbOKOnly + vbInformation, "注意"
txtPwAgain.SetFocus
Exit Sub
End If
If txtPassword.Text <> txtPwAgain.Text Then
MsgBox "兩次密碼不相同,請重新填寫!", vbOKOnly + vbInformation, "注意"
txtPassword.Text = ""
txtPwAgain.Text = ""
txtPassword.SetFocus
Exit Sub
End If
On Error GoTo exit1
If Not IsExistUser(txtUserName, "") Then
'添加用戶
DataE.cmdAdd txtUserName, txtPassword, txtRealname, txtUnit, Now, udAge, Usertype, State
MsgBox "注冊成功!", vbOKOnly + vbInformation, "注意"
Unload Me
frmSearch.Show
Else
MsgBox "用戶已經存在!請重新注冊一個新的用戶名", vbOKOnly + vbInformation, "注意"
txtUserName.Text = ""
txtPassword.Text = ""
txtPwAgain.Text = ""
txtUserName.SetFocus
End If
Exit Sub
exit1:
MsgBox "數據未成功寫入數據庫!", vbOKOnly + vbInformation, "錯誤"
Exit Sub
End Sub
Private Sub Form_Load()
txtAge.Text = CStr(udAge.Value)
Register.Height = 5800
Register.Width = 5800
Register.Top = 2000
Register.Left = 4000
mdiFrm.mnuReg.Enabled = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
mdiFrm.mnuReg.Enabled = True
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -