?? publicmodule.bas
字號:
Attribute VB_Name = "publicmodule"
'******************數據庫操作通用過程********************
Option Explicit
'加載數據庫
Public Sub loadmdb(ado As Adodc)
Dim a As String
a = App.Path
ado.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & a & "\library.mdb;Persist Security Info=False"
ado.CommandType = adCmdTable
ado.RecordSource = "書籍總表"
ado.Refresh
End Sub
'記錄瀏覽
Public Sub explorrecord(ado As Adodc, dgrid As DataGrid, tablename As String)
ado.CommandType = adCmdTable
ado.RecordSource = tablename
ado.Refresh
dgrid.Caption = tablename
End Sub
'記錄查詢
Public Sub selectrecord(ado As Adodc, dgrid As DataGrid, tablename As String, wordname As String, serchtext As String)
ado.CommandType = adCmdText
ado.RecordSource = "select * from " & tablename & " where " & wordname & " like " & "'%" & serchtext & "%'"
ado.Refresh
dgrid.Caption = ""
End Sub
'確定符合特定條件的記錄
Public Sub lockrecord(ado As Adodc, tablename As String, wordname As String, serchtext As String)
ado.CommandType = adCmdText
ado.RecordSource = "select * from " & tablename & " where " & wordname & " =" & "'" & serchtext & "'"
ado.Refresh
End Sub
'書籍自動編號
Public Function autobooknum(ado As Adodc, tablename As String) As String
Dim num As Long
ado.CommandType = adCmdTable
ado.RecordSource = tablename
ado.Refresh
ado.Recordset.MoveFirst
Do While Not ado.Recordset.EOF
If Val(ado.Recordset!書號) > num Then
num = Val(ado.Recordset!書號)
End If
ado.Recordset.MoveNext
Loop
autobooknum = CStr(num + 1)
End Function
'學生自動編號
Public Function autostudentnum(ado As Adodc, tablename As String) As String
Dim num As Long
ado.CommandType = adCmdTable
ado.RecordSource = tablename
ado.Refresh
ado.Recordset.MoveFirst
Do While Not ado.Recordset.EOF
If Val(ado.Recordset!學號) > num Then
num = Val(ado.Recordset!學號)
End If
ado.Recordset.MoveNext
Loop
autostudentnum = CStr(num + 1)
End Function
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -