⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 用Visual Basic编写的压缩Access文件软件
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   2985
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4455
   LinkTopic       =   "Form1"
   ScaleHeight     =   2985
   ScaleWidth      =   4455
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command4 
      Caption         =   "Save As"
      Height          =   375
      Left            =   240
      TabIndex        =   4
      Top             =   2400
      Width           =   1095
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   720
      TabIndex        =   1
      Top             =   600
      Width           =   2535
   End
   Begin VB.CommandButton Command3 
      Caption         =   "Exit"
      Height          =   375
      Left            =   2400
      TabIndex        =   3
      Top             =   1680
      Width           =   1335
   End
   Begin VB.CommandButton Command2 
      Caption         =   "Compact"
      Height          =   375
      Left            =   840
      TabIndex        =   2
      Top             =   1680
      Width           =   1215
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   240
      Top             =   0
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.CommandButton Command1 
      Caption         =   ">>"
      Height          =   375
      Left            =   3240
      TabIndex        =   0
      Top             =   600
      Width           =   375
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim txt As String
Private Sub Command1_Click()
    Dim Fname As String
    CommonDialog1.Filter = "Access 文件(*.MDB)|*.MDB|文本文件 (*.Txt)|*.Txt|所有文件 (*.*)|*.*"  '设置检索文件类型
    CommonDialog1.FileName = ""         '设置要的文件名
    CommonDialog1.Action = 1           'Actin方法等于1为打开CommonDialog窗口,等于 CommonDialog1.ShowOpen
    
    If Err <> 32755 Then
        'Fname = CommonDialog1.FileName
        Form1.Caption = CommonDialog1.FileName                    '将窗口标题改为文件名
    End If

   ' CommonDialog1.ShowOpen
    Text1.Text = CommonDialog1.FileName
    
    CompactFile = Text1.Text

End Sub

Private Sub Command2_Click()
Dim TmpStr1 As String
Dim TmpStr2 As String
Dim TmpStr3 As Integer
Dim TmpMDB As String
On Error Resume Next
'CommonDialog1.Filter = "Access 文件(*.MDB)|*.MDB|文本文件 (*.Txt)|*.Txt|所有文件 (*.*)|*.*"
If Text1.Text = "" Then
    MsgBox "文件名称为空,请选择Access 数据库文件!!!", vbOKOnly + vbInformation, "Test"
    Text1.SetFocus
    Exit Sub
End If
TmpStr1 = Text1.Text
TmpStr2 = ".mdb"
TmpStr3 = InStrRev(TmpStr1, TmpStr2, Len(TmpStr1))
TmpMDB = Mid$(TmpStr1, TmpStr3, 4)

If Text1.Text = "" Or TmpMDB <> TmpStr2 Then
    MsgBox "文件名称为空或文件不对,请选择Access 数据库文件!!!", vbOKOnly + vbInformation, "Test"
    Text1.SetFocus
Else
        CompactJetDatabase CompactFile, True
End If
    If Err.Number <> 0 Then
        MsgBox "没有找到该文件,请打开正确的文件!!!", vbOKOnly + vbInformation, "Test"
    End If
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Command4_Click()
Dim Location As String
    If Text1.Text <> "" Then
        txt = Text1.Text
        CommonDialog1.Filter = "Access 文件(*.MDB)|*.MDB|文本文件 (*.Txt)|*.Txt|所有文件 (*.*)|*.*"
        'initdiv = "E:\"  '默认路径
        CommonDialog1.FileName = txt  '默认文件名
        CommonDialog1.ShowSave
        'FileCopy CompactFile, Location
    Else
        MsgBox "文件不存在,请选择文件!!!", vbOKOnly + vbInformation, "Test"
    End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    SendKeys "{TAB}"
End If
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -