?? memberre.frm
字號:
Width = 480
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "電子郵件"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 240
Left = 360
TabIndex = 19
Top = 2700
Width = 960
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "電話"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 240
Left = 600
TabIndex = 18
Top = 3300
Width = 480
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "聯系地址"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 240
Left = 360
TabIndex = 17
Top = 4500
Width = 960
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "郵編"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 240
Left = 600
TabIndex = 16
Top = 5100
Width = 480
End
Begin VB.Label Label10
AutoSize = -1 'True
Caption = "身份證號碼"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 240
Left = 240
TabIndex = 15
Top = 3900
Width = 1200
End
End
Begin VB.Frame Frame2
Height = 1095
Left = 480
TabIndex = 24
Top = 6480
Width = 5895
End
Begin VB.Label Label9
AutoSize = -1 'True
Caption = "會員信息注冊"
BeginProperty Font
Name = "宋體"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF00FF&
Height = 300
Left = 2400
TabIndex = 13
Top = 240
Width = 1800
End
End
Attribute VB_Name = "MemberRE"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim com As Command
Dim rst As Recordset
Private Sub CancelBT_Click()
Unload Me
End Sub
Private Sub ClearBT_Click()
For Each Control In MemberRE
If TypeOf Control Is TextBox Then
If Control <> TID Then
Control.Text = ""
End If
End If
Next
End Sub
Private Sub Form_Load()
Set com = New Command
Set rst = New Recordset
addid
'MemberRE.Tname.SetFocus
End Sub
Private Sub OkBt_Click()
For Each Control In MemberRE
If TypeOf Control Is TextBox Then
If Control <> TID Then
If Trim(Control.Text) = "" Then
MsgBox "請輸入完整信息"
Exit Sub
End If
End If
End If
Next
If Len(Tname.Text) > 15 Then
MsgBox "姓名過長!請檢查!"
Tname.SetFocus
Exit Sub
End If
If Asc(Trim(TAge.Text)) > 57 Or Asc(Trim(TAge.Text)) < 48 Then
MsgBox "您的年齡有問題!請輸入數字!"
TAge.SetFocus
ElseIf Len(Trim(TAge.Text)) > 3 Then
MsgBox "您的年齡有那么大嘛!請檢查!"
TAge.SetFocus
ElseIf Trim(TAge.Text) = 0 Then
MsgBox "0歲的您也能看電影嘛!"
TAge.SetFocus
Exit Sub
End If
If ComboSex.Text = "" Then
MsgBox "請選擇您的性別!"
ComboSex.SetFocus
End If
If Len(Trim(TEmail.Text)) > 30 Then
MsgBox "電子郵件過長!請檢查!"
TEmail.SetFocus
Exit Sub
End If
If MemberRE.checkemail(TEmail.Text) = 0 Then
MsgBox "電子郵件輸入有誤!請檢查!"
TEmail.SetFocus
Exit Sub
End If
If Asc(Trim(TPhone.Text)) > 57 Or Asc(Trim(TPhone.Text)) < 48 Then
MsgBox "電話號碼有誤!請輸入數字!"
TPhone.SetFocus
ElseIf Len(Trim(TPhone.Text)) > 13 Or Len(Trim(TPhone.Text)) < 8 Then
MsgBox "電話號碼有誤!請檢查!"
TPhone.SetFocus
Exit Sub
End If
If Asc(Trim(TCardnum.Text)) > 57 Or Asc(Trim(TCardnum.Text)) < 48 Then
MsgBox "身份證號碼有誤!請輸入數字!"
TCardnum.SetFocus
ElseIf Len(Trim(TCardnum.Text)) > 18 Or Len(Trim(TCardnum.Text)) < 15 Then
MsgBox "身份證號碼有誤!請檢查!"
TCardnum.SetFocus
Exit Sub
End If
If Asc(Trim(TPostcode.Text)) > 57 Or Asc(Trim(TPostcode.Text)) < 48 Then
MsgBox "郵政編碼有誤!請輸入數字!"
TPostcode.SetFocus
ElseIf Len(Trim(TPostcode.Text)) > 6 Then
MsgBox "郵編過長!請檢查!"
TPostcode.SetFocus
Exit Sub
End If
Dim id, name, money, age, sex, email, address, postcode, phone, cardnum As String
id = TID.Text
name = Tname.Text
age = TAge.Text
sex = ComboSex.Text
email = TEmail.Text
address = TAddress.Text
postcode = TPostcode.Text
phone = TPhone.Text
cardnum = TCardnum.Text
money = TMoney.Text
'On Error GoTo err
'com.ActiveConnection = con
rst.Open "insert Member values('" & id & "','" & name & "'," & money & ",'" & age & "','" & sex & "','" & email & "','" & _
address & "','" & postcode & "','" & phone & "','" & cardnum & "')", con, adOpenDynamic, adLockOptimistic
MsgBox "您的信息注冊成功!:)歡迎光臨!"
Unload Me
Exit Sub
err:
MsgBox "請確認數據庫是否連接!"
End Sub
Public Function checkemail(email As String)
Dim a, b, n As Integer
n = Len(email)
a = 0
b = 0
For ctr = 1 To n
If Mid(email, ctr, 1) < "#" And Mid(email, ctr, 1) > "~" And Mid(email, ctr, 1) = "?" Then
checkemail = 0
Exit Function
End If
If Mid(email, ctr, 1) = "@" Then
a = a + 1
End If
If Mid(email, ctr, 1) = "." Then
b = 1
End If
Next ctr
If a = 1 And b = 1 Then
checkemail = 1
Exit Function
End If
checkemail = 0
End Function
Public Sub addid()
Dim id As String
'Dim rst As Recordset
'Set rst = New Recordset
'On Error GoTo err
com.ActiveConnection = con
rst.Open "select cMemberId from Member", con, adOpenDynamic, adLockOptimistic
If rst.EOF = True Then
id = "00001"
Else
id = getid(Trim(rst!cMemberID))
rst.MoveNext
Do While rst.EOF = False
If id = Trim(rst!cMemberID) Then
id = getid(Trim(rst!cMemberID))
rst.MoveNext
Else
Exit Do
End If
Loop
End If
TID.Text = id
'rst.MoveFirst
rst.Close
Exit Sub
err:
MsgBox "數據庫還未連接!"
Unload Me
End Sub
Private Function getid(temp As String)
temp = temp + 1
If temp < 10 Then
getid = "0000" & temp
Exit Function
End If
If temp < 100 Then
getid = "000" & temp
Exit Function
End If
If temp < 1000 Then
getid = "00" & temp
Exit Function
End If
If temp < 10000 Then
getid = "0" & temp
Exit Function
Else
getid = temp
End If
End Function
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -