practice12_5.frm

来自「深圳大学的vb上机与教学的课件」· FRM 代码 · 共 133 行

FRM
133
字号
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3975
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5520
   LinkTopic       =   "Form1"
   ScaleHeight     =   3975
   ScaleWidth      =   5520
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command1 
      Caption         =   "文件复制"
      Height          =   375
      Left            =   2280
      TabIndex        =   8
      Top             =   1560
      Width           =   975
   End
   Begin VB.DirListBox Dir1 
      Height          =   1350
      Left            =   240
      TabIndex        =   7
      Top             =   960
      Width           =   1815
   End
   Begin VB.DirListBox Dir2 
      Height          =   1350
      Left            =   3480
      TabIndex        =   6
      Top             =   960
      Width           =   1815
   End
   Begin VB.FileListBox File2 
      Height          =   1350
      Left            =   3480
      TabIndex        =   3
      Top             =   2520
      Width           =   1815
   End
   Begin VB.DriveListBox Drive2 
      Height          =   300
      Left            =   3480
      TabIndex        =   2
      Top             =   480
      Width           =   1815
   End
   Begin VB.FileListBox File1 
      Height          =   1350
      Left            =   240
      TabIndex        =   1
      Top             =   2520
      Width           =   1815
   End
   Begin VB.DriveListBox Drive1 
      Height          =   300
      Left            =   240
      TabIndex        =   0
      Top             =   480
      Width           =   1815
   End
   Begin VB.Label Label2 
      Caption         =   "目标:"
      Height          =   255
      Left            =   3480
      TabIndex        =   5
      Top             =   120
      Width           =   615
   End
   Begin VB.Label Label1 
      Caption         =   "源:"
      Height          =   255
      Left            =   240
      TabIndex        =   4
      Top             =   120
      Width           =   615
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
   Drive1.Drive = "c:\"                ' 初始化驱动器列表框
   Drive2.Drive = "c:\"
   Rem 设置文件属性--如显示只读文件(实验时去掉注释)
   ' File1.ReadOnly = True
   ' File1.Archive = False
   ' File1.System = False
   ' File1.Normal = False
   ' File1.Hidden = False
   Rem 设置文件过滤条件(实验时可去掉注释)
   ' File1.Pattern = "*.txt;*.exe"
End Sub
Private Sub Drive1_Change()
   ' 使驱动器列表框和目录列表框同步
   Dir1.Path = Drive1.Drive
End Sub
Private Sub Dir1_Change()
   ' 使目录列表框和文件列表框同步
   File1.Path = Dir1.Path
End Sub
Private Sub Drive2_Change()
   ' 使驱动器列表框和目录列表框同步
   Dir2.Path = Drive2.Drive
End Sub
Private Sub Dir2_Change()
   ' 使目录列表框和文件列表框同步
   File2.Path = Dir2.Path
End Sub

Private Sub Command1_Click()
   Rem 本例没考虑目标驱动器上文件已存在的情况!!!请读者自己完善!
   If File1.FileName = "" Then
      MsgBox ("必须选择一个文件!")
   Else
      If Right(Dir1.Path, 1) = "\" Then
         fsource = Dir1.Path + File1.FileName
      Else
         fsource = Dir1.Path + "\" + File1.FileName
      End If
      If Right(Dir2.Path, 1) = "\" Then
         fdest = Dir2.Path + File1.FileName
      Else
         fdest = Dir2.Path + "\" + File1.FileName
      End If

   End If
   FileCopy fsource, fdest
End Sub

⌨️ 快捷键说明

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