?? module1.bas
字號:
Attribute VB_Name = "Module1"
Option Explicit
Private rs As New ADODB.Recordset
Private strconn As String
Private strsql As String
Private a1 As Integer
Private b1 As Integer
Private rs3 As New ADODB.Recordset
Private strconn3 As String
Private strsql3 As String
Private s1 As String
Private s2 As String
Sub add1()
On Error Resume Next
strconn = "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\horse.mdb"
strsql = "select * from horse1"
With rs
If .State = adStateOpen Then
.Close
End If
.ActiveConnection = strconn
.Source = strsql
.LockType = adLockOptimistic
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.Open
If Form3.Text1.Text = "" Then
MsgBox "編號和姓名是必填字段"
Exit Sub
End If
If Form3.Text2.Text = "" Then
MsgBox "編號和姓名是必填字段"
Exit Sub
End If
If Form3.Text3.Text = "" Then
Form3.Text3.Text = "null"
End If
.AddNew
rs(0) = Form3.Text1.Text
rs(1) = Form3.Text2.Text
rs(2) = Form3.Text3.Text
.Update
End With
Set Form1.DataGrid1.DataSource = rs
Set Form1.Adodc1.Recordset = rs
With Form1.DataGrid1
.Columns(0).Width = 900
.Columns(1).Width = 1600
.Columns(2).Width = 4000
End With
Form1.Adodc1.Caption = "當前記錄為:" & Form1.Adodc1.Recordset.AbsolutePosition & "/" & Form1.Adodc1.Recordset.RecordCount
Form3.Text1.Text = ""
Form3.Text2.Text = ""
Form3.Text3.Text = ""
End Sub
Sub add2()
On Error Resume Next
strconn = "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\horse.mdb"
strsql = "select * from horse2"
With rs
If .State = adStateOpen Then
.Close
End If
.ActiveConnection = strconn
.Source = strsql
.LockType = adLockOptimistic
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.Open
If Form4.Text1.Text = "" Then
MsgBox "請填寫正確編號"
Exit Sub
End If
If Form4.Text2.Text = "" Then
MsgBox "請填寫正確編號"
Exit Sub
End If
If Form4.Text3.Text = "" Then
MsgBox "請填寫正確編號"
Exit Sub
End If
If Form4.Combo2.Text = "請選擇場次" Then
MsgBox "請選擇場次"
Exit Sub
End If
If Form4.Combo2.Text = "第一場" Then
b1 = 1
End If
If Form4.Combo2.Text = "第二場" Then
b1 = 2
End If
If Form4.Combo2.Text = "第三場" Then
b1 = 3
End If
If Form4.Combo2.Text = "第四場" Then
b1 = 4
End If
If Form4.Combo2.Text = "第五場" Then
b1 = 5
End If
If Form4.Combo2.Text = "第六場" Then
b1 = 6
End If
If Form4.Combo2.Text = "第七場" Then
b1 = 7
End If
If Form4.Combo2.Text = "第八場" Then
b1 = 8
End If
If Form4.Combo2.Text = "第九場" Then
b1 = 9
End If
If Form4.Combo2.Text = "第十場" Then
b1 = 10
End If
If Form4.Combo2.Text = "第十一場" Then
b1 = 11
End If
If Form4.Combo2.Text = "第十二場" Then
b1 = 12
End If
If Form4.Combo2.Text = "第十三場" Then
b1 = 13
End If
If Form4.Combo2.Text = "第十四場" Then
b1 = 14
End If
If Form4.Combo2.Text = "第十五場" Then
b1 = 15
End If
.AddNew
rs(0) = Form4.Text1.Text
rs(1) = Form4.Text2.Text
rs(2) = Form4.Combo2.Text
rs(3) = b1
rs(4) = Form4.Text3.Text
.Update
End With
strconn = "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\horse.mdb"
strsql = "select 場次,編號,姓名,資料 from horse2"
With rs
If .State = adStateOpen Then
.Close
End If
.ActiveConnection = strconn
.Source = strsql
.LockType = adLockOptimistic
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.Open
End With
Set Form2.DataGrid1.DataSource = rs
Set Form2.Adodc1.Recordset = rs
With Form2.DataGrid1
.Columns(0).Width = 1500
.Columns(1).Width = 1000
.Columns(2).Width = 1500
.Columns(3).Width = 1500
End With
Form2.Adodc1.Caption = "當前記錄為:" & Form2.Adodc1.Recordset.AbsolutePosition & "/" & Form2.Adodc1.Recordset.RecordCount
Form4.Text1.Text = ""
Form4.Text2.Text = ""
Form4.Text3.Text = ""
Form4.Combo2.Text = "請選擇場次"
End Sub
Sub xudi()
strconn = "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\horse.mdb"
strsql = "select * from horse2"
With rs
If .State = adStateOpen Then
.Close
End If
.ActiveConnection = strconn
.Source = strsql
.LockType = adLockOptimistic
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.Open
End With
strconn3 = "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\horse.mdb"
strsql3 = "select * from horse1"
With rs3
If .State = adStateOpen Then
.Close
End If
.ActiveConnection = strconn3
.Source = strsql3
.LockType = adLockOptimistic
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.Open
End With
rs3.MoveFirst
Do While Not rs3.EOF
rs.MoveFirst
's1 = ""
'If ((rs3(2) <> Null) Or (rs3(2) <> "")) Then
s1 = rs3(0)
s2 = rs3(2)
rs.MoveFirst
Do While Not rs.EOF
If rs(0) = s1 Then
rs(1) = rs3(1)
rs(0) = s1
rs(4) = s2
End If
rs.MoveNext
Loop
'Else
'rs(1) = rs3(1)
'rs(4) = Null
'End If
rs3.MoveNext
Loop
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -