?? form2.frm
字號:
VERSION 5.00
Begin VB.Form Form2
Caption = "添加用戶系統"
ClientHeight = 3360
ClientLeft = 60
ClientTop = 450
ClientWidth = 5370
LinkTopic = "Form2"
ScaleHeight = 3360
ScaleWidth = 5370
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command2
Caption = "取消"
Height = 375
Left = 4080
TabIndex = 13
Top = 2760
Width = 735
End
Begin VB.CommandButton Command1
Caption = "提交"
Height = 375
Left = 2760
TabIndex = 12
Top = 2760
Width = 735
End
Begin VB.Frame Frame2
Caption = "用戶權限"
Height = 1935
Left = 3720
TabIndex = 7
Top = 480
Width = 1455
Begin VB.OptionButton Option2
Caption = "Option2"
Height = 375
Left = 240
TabIndex = 9
Top = 1200
Width = 255
End
Begin VB.OptionButton Option1
Caption = "Option1"
Height = 255
Left = 240
TabIndex = 8
Top = 600
Width = 255
End
Begin VB.Label Label5
Caption = "只讀用戶"
Height = 255
Left = 600
TabIndex = 11
Top = 1200
Width = 735
End
Begin VB.Label Label4
Caption = "管理員"
Height = 255
Left = 600
TabIndex = 10
Top = 600
Width = 615
End
End
Begin VB.Frame Frame1
Caption = "添加用戶"
Height = 1935
Left = 480
TabIndex = 0
Top = 480
Width = 3015
Begin VB.TextBox Text3
Height = 375
IMEMode = 3 'DISABLE
Left = 1320
PasswordChar = "*"
TabIndex = 6
Top = 1440
Width = 1095
End
Begin VB.TextBox Text2
Height = 375
IMEMode = 3 'DISABLE
Left = 1320
PasswordChar = "*"
TabIndex = 4
Top = 840
Width = 1095
End
Begin VB.TextBox Text1
Height = 405
Left = 1320
TabIndex = 2
Top = 240
Width = 1095
End
Begin VB.Label Label3
Caption = "確認密碼"
Height = 255
Left = 360
TabIndex = 5
Top = 1560
Width = 735
End
Begin VB.Label Label2
Caption = "密碼"
Height = 255
Left = 360
TabIndex = 3
Top = 960
Width = 615
End
Begin VB.Label Label1
Caption = "用戶名"
Height = 255
Left = 360
TabIndex = 1
Top = 360
Width = 615
End
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim cnn1 As ADODB.Connection
Dim userpword As ADODB.Recordset
Dim strcnn As String
If Trim(Text1.Text) = "" Then
MsgBox "請輸入用戶名稱!", vbOKOnly + vbExclamation, "警告"
Text1.SetFocus
Exit Sub
Else
strcnn = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=db1"
Set cnn1 = New ADODB.Connection
cnn1.Open strcnn
Set userpword = New ADODB.Recordset
userpword.LockType = adLockOptimistic
userpword.Open "select * from use", cnn1, , , adCmdText
While (userpword.EOF = False)
If Trim(userpword.Fields(0)) = Trim(Text1.Text) Then
MsgBox "用戶已經存在,請重新輸入用戶名!", vbOKOnly + vbExclamation, "警告"
Text1.SetFocus
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Exit Sub
Else
userpword.MoveNext
End If
Wend
End If
If Trim(Text2.Text) <> Trim(Text3.Text) Then
MsgBox "兩次輸入密碼不一樣,請確認!", vbOKOnly + vbExclamation, "警告"
Text2.SetFocus
Text2.Text = ""
Text3.Text = ""
Exit Sub
Else
If Text2.Text = "" Then
MsgBox "密碼不能為空!", vbOKOnly + vbExclamation, "警告"
Text2.SetFocus
Text2.Text = ""
Text3.Text = ""
Else
userpword.AddNew
userpword.Fields(0) = Trim(Text1.Text)
userpword.Fields(1) = Trim(Text2.Text)
If Option1.Value Then
userpword.Fields(2) = "y"
Else
userpword.Fields(3) = "y"
End If
userpword.Update
userpword.Close
MsgBox "添加用戶成功!", vbOKOnly + vbExclamation, "添加用戶"
End If
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -