?? 增加用戶r.frm
字號:
VERSION 5.00
Begin VB.Form Frm_AddUser
BorderStyle = 1 'Fixed Single
Caption = "增加用戶"
ClientHeight = 3900
ClientLeft = 45
ClientTop = 330
ClientWidth = 4890
Icon = "增加用戶r.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3900
ScaleWidth = 4890
StartUpPosition = 2 '屏幕中心
Begin VB.ComboBox Combo1
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 330
Left = 2040
TabIndex = 9
Text = "Combo1"
Top = 2520
Width = 1815
End
Begin VB.CommandButton Command2
Caption = "退出"
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3000
TabIndex = 7
Top = 3240
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "確定"
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 840
TabIndex = 6
Top = 3240
Width = 1215
End
Begin VB.TextBox Text3
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
IMEMode = 3 'DISABLE
Left = 2040
PasswordChar = "*"
TabIndex = 5
Text = "Text3"
Top = 1920
Width = 1815
End
Begin VB.TextBox Text2
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
IMEMode = 3 'DISABLE
Left = 2040
PasswordChar = "*"
TabIndex = 3
Text = "Text2"
Top = 1320
Width = 1815
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2040
TabIndex = 1
Text = "Text1"
Top = 720
Width = 1815
End
Begin VB.Label Label4
Caption = "身份:"
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 1320
TabIndex = 8
Top = 2520
Width = 735
End
Begin VB.Label Label3
Caption = "確定密碼:"
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 960
TabIndex = 4
Top = 1920
Width = 1095
End
Begin VB.Label Label2
Caption = "密碼:"
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 1320
TabIndex = 2
Top = 1320
Width = 855
End
Begin VB.Label Label1
Caption = "用戶名:"
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 1200
TabIndex = 0
Top = 720
Width = 855
End
End
Attribute VB_Name = "Frm_AddUser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim myCon As New ADODB.Connection
Dim myRs As New ADODB.Recordset
Private Sub Command1_Click()
Dim strName, strPass, strPassAgain, strShenFen As String
strName = Trim(Text1.Text)
strPass = Trim(Text2.Text)
strPassAgain = Trim(Text3.Text)
strShenFen = Trim(Combo1.Text)
If strName = "" Or strPass = "" Or strPassAgain = "" Or strShenFen = "" Then
MsgBox "請填寫完整所有資料!", vbOKOnly, "警告"
Text1.SetFocus
Exit Sub
End If
myCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=信息.mdb;"
myRs.Open "select * from 用戶資料 where 用戶名='" & strName & "'", myCon
If Not myRs.EOF Then
Text1.SetFocus
MsgBox "該用戶名已經存在,請使用其他用戶名!", vbOKOnly, "警告"
myRs.Close
myCon.Close
Exit Sub
End If
If strPass <> strPassAgain Then
MsgBox "兩次輸入的密碼不同!", vbOKOnly, "警告"
Text3.SetFocus
myRs.Close
myCon.Close
Exit Sub
End If
myRs.Close
myRs.CursorType = adOpenKeyset
myRs.LockType = adLockOptimistic
myRs.Open "用戶資料", myCon, 3, 2
myRs.AddNew
myRs!用戶名 = Text1.Text
myRs!密碼 = Text2.Text
'myRs!確定密碼 = Text3.Text
myRs!身份 = Combo1.Text
myRs.Update
myRs.Close
myCon.Close
MsgBox "注冊成功!", vbOKOnly, "提示"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Combo1.Text = ""
Frm_LiulanUser.Adodc1.Refresh
Frm_LiulanUser.DataGrid1.Refresh
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Combo1.Text = ""
Combo1.AddItem ("管理員")
Combo1.AddItem ("用戶")
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -