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

📄 form1.frm

📁 vb做的文件分割器
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1 
   Caption         =   "22—文件分割器"
   ClientHeight    =   4110
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7785
   Icon            =   "Form1.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   4110
   ScaleWidth      =   7785
   StartUpPosition =   3  '窗口缺省
   Begin VB.Frame Frame2 
      Caption         =   "文件合并"
      Height          =   1815
      Left            =   120
      TabIndex        =   6
      Top             =   2040
      Width           =   7575
      Begin VB.CommandButton Command2 
         Caption         =   "..."
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   7.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   6600
         TabIndex        =   15
         Top             =   240
         Width           =   375
      End
      Begin VB.TextBox txtOutputFile 
         Height          =   285
         Left            =   2400
         TabIndex        =   10
         Top             =   720
         Width           =   4095
      End
      Begin VB.CommandButton cmdUnsplit 
         Caption         =   "合并"
         Height          =   375
         Left            =   2400
         TabIndex        =   8
         Top             =   1200
         Width           =   1215
      End
      Begin VB.TextBox txtTemplateName 
         Height          =   285
         Left            =   2400
         TabIndex        =   7
         Top             =   240
         Width           =   4095
      End
      Begin VB.Label Label1 
         Caption         =   "输出文件:"
         Height          =   255
         Index           =   2
         Left            =   1320
         TabIndex        =   11
         Top             =   720
         Width           =   975
      End
      Begin VB.Label Label1 
         Caption         =   "合并模板:"
         Height          =   255
         Index           =   3
         Left            =   1320
         TabIndex        =   9
         Top             =   240
         Width           =   975
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "文件分割"
      Height          =   1815
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   7575
      Begin MSComDlg.CommonDialog CommonDialog1 
         Left            =   5760
         Top             =   1200
         _ExtentX        =   847
         _ExtentY        =   847
         _Version        =   393216
      End
      Begin VB.CommandButton Command1 
         Caption         =   "..."
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   7.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   6600
         TabIndex        =   14
         Top             =   240
         Width           =   375
      End
      Begin VB.TextBox txtFileName 
         Height          =   285
         Left            =   2400
         TabIndex        =   3
         Top             =   240
         Width           =   4095
      End
      Begin VB.CommandButton cmdSplit 
         Caption         =   "分割"
         Height          =   375
         Left            =   2400
         TabIndex        =   2
         Top             =   1200
         Width           =   1215
      End
      Begin VB.TextBox txtFileLength 
         Height          =   285
         Left            =   2400
         TabIndex        =   1
         Top             =   720
         Width           =   1215
      End
      Begin VB.Label Label1 
         Caption         =   "M"
         Height          =   255
         Index           =   5
         Left            =   3720
         TabIndex        =   13
         Top             =   720
         Width           =   255
      End
      Begin VB.Label Label1 
         Height          =   255
         Index           =   4
         Left            =   4080
         TabIndex        =   12
         Top             =   720
         Width           =   1695
      End
      Begin VB.Label Label1 
         Caption         =   "分割后大小:"
         Height          =   255
         Index           =   1
         Left            =   1200
         TabIndex        =   5
         Top             =   720
         Width           =   1095
      End
      Begin VB.Label Label1 
         Caption         =   "文件路径:"
         Height          =   255
         Index           =   0
         Left            =   1320
         TabIndex        =   4
         Top             =   240
         Width           =   1095
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub cmdSplit_Click()
Dim err_descr As String
Dim i As Long, x As Long, xw%
On Error GoTo error1
FilesLen = FileLen(txtFileName.Text)
x = CInt((FilesLen / 1024) / (1024 * Val(txtFileLength.Text))) + 2
Label1(4) = "分割数量:" & Trim(Str(x))

xw = MsgBox("是否分割?", 32 + 1, "询问")
    If xw = 1 Then
    If Not SplitFile(txtFileName.Text, 0, err_descr, CLng(txtFileLength.Text) * 1024 * 1024) Then
        MsgBox err_descr
    Else
        MsgBox "分割成功!", 48, "祝贺"
    End If
    End If
Exit Sub
On Error GoTo 0
error1:
MsgBox "请填写详细信息!", 48, "提示"
End Sub


Private Sub cmdUnsplit_Click()
Dim err_descr As String
On Error GoTo error2
    If Not ReassembleFile(txtTemplateName.Text, False, txtOutputFile.Text) Then
        MsgBox err_descr
    Else
        MsgBox "合并成功!", 48, "祝贺"
    End If
Exit Sub
On Error GoTo 0
error2:
MsgBox "请填写详细信息!", 48, "提示"
End Sub

Private Sub Command1_Click()
 With CommonDialog1
      .FileName = ""
      .ShowOpen
      If .FileName <> "" Then
       txtFileName.Text = .FileName
      End If
   End With
End Sub

Private Sub Command2_Click()
Dim s, m As String
Dim i As Integer
 With CommonDialog1
      .FileName = ""
      .ShowOpen
      If .FileName <> "" Then
       s = .FileName
       txtTemplateName.Text = s
      End If
   End With
   If Len(s) < 4 Then Exit Sub
   m = Mid(s, 1, Len(s) - 4)
   For i = Len(m) To 1 Step -1
   If Mid(m, i, 1) = "\" Then Exit For
   Next
   m = Mid(m, i + 1)
  txtOutputFile.Text = txtOutputFile.Text & m
End Sub

Private Sub Form_Load()
Dim dir_name As String

    dir_name = App.Path
    If Right$(dir_name, 1) <> "\" Then _
        dir_name = dir_name & "\"
  '  txtFileName.Text = dir_name
  '  txtTemplateName.Text = dir_name & "  .tpl"
    txtOutputFile.Text = dir_name
End Sub

⌨️ 快捷键说明

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