?? frmadduser.frm
字號:
VERSION 5.00
Begin VB.Form frmadduser
BorderStyle = 1 'Fixed Single
Caption = "添加用戶"
ClientHeight = 3195
ClientLeft = 45
ClientTop = 330
ClientWidth = 4680
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton cmdcanel
Caption = "取 消"
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2400
TabIndex = 7
Top = 2280
Width = 1455
End
Begin VB.CommandButton cmdOK
Caption = "確 定"
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 480
TabIndex = 6
Top = 2280
Width = 1455
End
Begin VB.TextBox txtpassword2
Height = 375
IMEMode = 3 'DISABLE
Left = 1560
PasswordChar = "*"
TabIndex = 5
Top = 1440
Width = 2175
End
Begin VB.TextBox txtpassword1
Height = 375
IMEMode = 3 'DISABLE
Left = 1560
PasswordChar = "*"
TabIndex = 4
Top = 960
Width = 2175
End
Begin VB.TextBox txtusername
Height = 375
Left = 1560
TabIndex = 3
Top = 480
Width = 2175
End
Begin VB.Label Label3
Alignment = 2 'Center
Caption = "請確認密碼"
BeginProperty Font
Name = "新宋體"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 2
Top = 1560
Width = 1215
End
Begin VB.Label Label2
Alignment = 2 'Center
Caption = "請輸入密碼"
BeginProperty Font
Name = "新宋體"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 1
Top = 1080
Width = 1215
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "請輸入用戶名"
BeginProperty Font
Name = "新宋體"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 0
Top = 600
Width = 1215
End
End
Attribute VB_Name = "frmadduser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdcanel_Click()
Unload Me
End Sub
Private Sub cmdok_Click()
Dim txtsql As String '用于存放SQL命令
Dim mrc As ADODB.Recordset '返回記錄集
'Dim cnn1 As ADODB.Recordset
Dim msgtext As String
If Trim(txtusername.Text) = "" Then '判斷是否輸入用戶名
MsgBox "用戶名不能為空,請輸入用戶名!", vbOKOnly + vbExclamation, "警告"
Exit Sub
txtusername.SetFocus
Else
txtsql = "select * from users" '查找數(shù)據(jù)庫中的信息
Set mrc = ExecuteSQL(txtsql, msgtext) '返回記錄集
While (mrc.EOF = False) '從記錄集中判斷用戶名是否存在
If Trim(mrc.Fields(0)) = Trim(txtusername.Text) Then
MsgBox "用戶名已經(jīng)存在,請重新輸入用戶名!", vbOKOnly + vbExclamation, "警告"
txtusername.SetFocus
txtusername.Text = ""
txtpassword1.Text = ""
txtpassword2.Text = ""
Exit Sub
Else
mrc.MoveNext '核對下一條記錄
End If
Wend
'mrc.Close
End If
If Trim(txtpassword1.Text) <> Trim(txtpassword2.Text) Then '判斷用戶兩次輸入密碼是否一致
MsgBox "兩次密碼輸入不一致", vbOKOnly + vbExclamation, "警告"
txtusername.SetFocus
txtusername.Text = ""
txtpassword1.Text = ""
txtpassword2.Text = ""
Else
If txtpassword1.Text = "" Then '判斷密碼是否為空
MsgBox "密碼不能為空", vbOKOnly + vbExclamation, "警告"
txtusername.SetFocus
txtusername.Text = ""
txtpassword1.Text = ""
txtpassword2.Text = ""
Else
'mrc.Update
txtsql = "select * from users" '查找數(shù)據(jù)庫中的信息
Set mrc = ExecuteSQL(txtsql, msgtext)
'mrc.Update
mrc.AddNew '添加新記錄
'mrc!user_id = Trim(txtusername.Text)
'mrc!user_pwd = Trim(txtpassword1.Text)
mrc.Fields(0) = Trim(txtusername.Text) '字段賦值
mrc.Fields(1) = Trim(txtpassword1.Text)
mrc.Update '更新數(shù)據(jù)庫
mrc.Close
Me.Hide
MsgBox "添加用戶成功", vbOKOnly + vbExclamation, "添加用戶"
End If
End If
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -