?? 添加用戶.frm
字號:
VERSION 5.00
Begin VB.Form Form10
BorderStyle = 3 'Fixed Dialog
Caption = "添加用戶"
ClientHeight = 4605
ClientLeft = 3285
ClientTop = 2775
ClientWidth = 5715
LinkTopic = "Form10"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 4605
ScaleWidth = 5715
ShowInTaskbar = 0 'False
Begin VB.CommandButton Command2
Caption = "取消"
BeginProperty Font
Name = "宋體"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 2760
TabIndex = 7
Top = 3360
Width = 1035
End
Begin VB.CommandButton Command1
Caption = "確認"
BeginProperty Font
Name = "宋體"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 1320
TabIndex = 6
Top = 3360
Width = 1035
End
Begin VB.TextBox Text3
Height = 400
IMEMode = 3 'DISABLE
Left = 2160
PasswordChar = "*"
TabIndex = 5
Top = 2520
Width = 2115
End
Begin VB.TextBox Text2
Height = 400
IMEMode = 3 'DISABLE
Left = 2160
PasswordChar = "*"
TabIndex = 4
Top = 1560
Width = 2115
End
Begin VB.TextBox Text1
Height = 400
Left = 2160
TabIndex = 3
Top = 600
Width = 2115
End
Begin VB.Label Label3
Caption = "請確認密碼:"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 600
TabIndex = 2
Top = 2600
Width = 1575
End
Begin VB.Label Label2
Caption = "請輸入密碼:"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 600
TabIndex = 1
Top = 1560
Width = 1515
End
Begin VB.Label Label1
Caption = "輸入用戶名:"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 600
TabIndex = 0
Top = 720
Width = 1425
End
End
Attribute VB_Name = "Form10"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Conn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Private Sub Command1_Click()
Dim Txtsql As String
Dim Mrc As ADODB.Recordset
'Set Cmd.ActiveConnection = Conn
'檢查輸入用戶名是否在數據庫中有同名記錄
If Trim(Text1.Text) = "" Then
MsgBox "請輸入用戶名稱!", vbExclamation, "出錯啦!"
Exit Sub
Else
Txtsql = "select * from 用戶表"
'Cmd.CommandText = Txtsql
'Cmd.CommandType = adCmdText
'Set Mrc = Cmd.Execute
Set Mrc = ExecuteSQL(Txtsql) 'g
While (Mrc.EOF = False)
If Trim(Mrc.Fields(0)) = Trim(Text1.Text) Then
MsgBox "用戶已經存在,請重新輸入!", , "出錯啦!"
Exit Sub
Else
Mrc.MoveNext
End If
Wend
End If
'檢查兩次密碼是否一致
If Trim(Text2.Text) <> Trim(Text3.Text) Then
MsgBox "兩次輸入的密碼不一樣,請確認!", , "出錯啦!"
Exit Sub
Else
If Text2.Text = "" Then
MsgBox "密碼不能為空!", vbExclamation, "出錯啦!"
Exit Sub
Else
Rs.AddNew
Rs("用戶名") = Trim(Text1.Text)
Rs("密碼") = Trim(Text3.Text)
Me.Hide
Rs.Update
MsgBox "添加用戶成功!", , "添加用戶!"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End If
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
connstr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\學生信息管理.mdb"
Conn.Open connstr
Rs.Open "用戶表", Conn, adOpenKeyset, adLockPessimistic
End Sub
Private Sub Form_Unload(Cancel As Integer)
Rs.Close
Conn.Close
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.SetFocus
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text3.SetFocus
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command1.SetFocus
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -