?? module1.bas
字號:
Attribute VB_Name = "Module1"
'調用API函數獲取文件所在的臨時路徑
Public Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, _
ByVal lpBuffer As String) As Long
Public Const MAX_PATH = 260
Public CompactFile As String
Public Sub CompactJetDatabase(Location As String, Optional BackupOriginal As Boolean = True)
Dim strBackupFile As String
Dim strTempFile As String
On Error GoTo CompactErr
'檢查數據庫文件是否存在
If Len(Dir(Location)) Then
'需要備份數據庫
If BackupOriginal = True Then
strBackupFile = GetTemporaryPath & "backup.mdb"
If Len(Dir(strBackupFile)) Then Kill strBackupFile
FileCopy Location, strBackupFile
End If
' 創建臨時文件名
strTempFile = GetTemporaryPath & "temp.mdb"
If Len(Dir(strTempFile)) Then Kill strTempFile
'通過DBEngine 壓縮數據庫文件并生成一個新的臨時temp.mdb文件在C:\Documents and Settings\Administrator\Local Settings\Temp目錄下
DBEngine.CompactDatabase Location, strTempFile
' 刪除原來的數據庫文件
Kill Location
' 拷貝剛剛壓縮過臨時數據庫文件至原來位置
FileCopy strTempFile, Location
' 刪除臨時文件
Kill strTempFile
Else
End If
CompactErr:
Exit Sub
End Sub
'獲取臨時路徑C:\Documents and Settings\Administrator\Local Settings\Temp
Public Function GetTemporaryPath()
Dim strFolder As String
Dim lngResult As Long
strFolder = String(MAX_PATH, 0) '什么意思
lngResult = GetTempPath(MAX_PATH, strFolder)
If lngResult <> 0 Then
GetTemporaryPath = Left(strFolder, InStr(strFolder, Chr(0)) - 1)
Else
GetTemporaryPath = ""
End If
End Function
Public Sub EnterTab(KeyAsciiValue As Integer)
If KeyAsciiValue = 13 Then
SendKeys "{TAB}"
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -