?? form1.frm
字號:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command3
Caption = "注冊"
Height = 375
Left = 2160
TabIndex = 6
Top = 2280
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "取消"
Height = 375
Left = 3600
TabIndex = 5
Top = 2280
Width = 975
End
Begin VB.CommandButton Command1
Caption = "登錄"
Height = 375
Left = 720
TabIndex = 4
Top = 2280
Width = 1215
End
Begin VB.TextBox Text2
Height = 375
IMEMode = 3 'DISABLE
Left = 1560
PasswordChar = "*"
TabIndex = 3
Top = 1440
Width = 1335
End
Begin VB.TextBox Text1
Height = 375
Left = 1560
TabIndex = 2
Top = 720
Width = 1335
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "密碼"
Height = 180
Left = 960
TabIndex = 1
Top = 1560
Width = 360
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "用戶名"
Height = 180
Left = 960
TabIndex = 0
Top = 840
Width = 540
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Private Sub Command1_Click()
Dim rststr As String
If Trim(Text1.Text) = "" Then
MsgBox "用戶名不能為空!", vbExclamation + vbOKOnly, "警告"
Text1.SetFocus
Exit Sub
End If
If Trim(Text2.Text) = "" Then
MsgBox "密碼不能為空!", vbExclamation + vbOKOnly, "警告"
Text2.SetFocus
Exit Sub
End If
rststr = "select * from user where [name]='" & Text1.Text & "' and [Password]='" & Text2.Text & "' "
rst.Open rststr, cnn, adOpenKeyset, adLockOptimistic, adCmdText
If rst.RecordCount >= 1 Then
Unload Me
frmMain.Show
rst.Close
Exit Sub
Else
MsgBox "未注冊,請先注冊", 32, "信息"
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Command3_Click()
Dim rststr As String
Dim pstr As String
rststr = "select * from user where ( user.name='" & Text1.Text & "') and (user.Password='" & Text2.Text & "')"
rst.Open rststr, cnn, adOpenKeyset, adLockOptimistic, adCmdText
If rst.RecordCount >= 1 Then
MsgBox "該用戶已經存在", , "信息"
rst.Close
Exit Sub
Else
rst.Close
End If
pstr = "insert into user([name],[password]) values('" & Text1.Text & "', '" & Text2.Text & "')"
cnn.Execute pstr
MsgBox "用戶注冊成功!!!!", , "信息"
End Sub
Private Sub Form_Load()
Dim strcnn As String
strcnn = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & App.Path & "\BookManage.mdb"
cnn.Open (strcnn)
End Sub
Private Sub Label3_Click()
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Text2.SetFocus
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Command1_Click
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -