【VB开源代码栏目提醒】:网学会员,鉴于大家对VB开源代码十分关注,论文会员在此为大家搜集整理了“frmFilePath.frm”一文,供大家参考学习!
VERSION 5.00
Begin VB.Form frmFilePath
Caption = "Form1"
ClientHeight = 5115
ClientLeft = 60
ClientTop = 345
ClientWidth = 8535
LinkTopic = "Form1"
ScaleHeight = 5115
ScaleWidth = 8535
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton comdCancel
Cancel = -1 'True
Caption = "取消"
Height = 375
Left = 6840
TabIndex = 9
Top = 4560
Width = 1335
End
Begin VB.CommandButton comdOK
Caption = "确定"
Default = -1 'True
Height = 375
Left = 5280
TabIndex = 8
Top = 4560
Width = 1335
End
Begin VB.FileListBox File1
Height = 3510
Left = 4920
TabIndex = 7
Top = 840
Width = 3495
End
Begin VB.TextBox txtFileName
Height = 300
Left = 840
TabIndex = 5
Top = 120
Width = 7575
End
Begin VB.DirListBox Dir1
Height = 2820
Left = 120
TabIndex = 1
Top = 1530
Width = 4575
End
Begin VB.DriveListBox Drive1
Height = 300
Left = 120
TabIndex = 0
Top = 840
Width = 4575
End
Begin
VB.Label Label4
AutoSize = -1 'True
Caption = "文件列表:"
Height = 180
Left = 4920
TabIndex = 6
Top = 600
Width = 810
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "文件名:"
Height = 180
Left = 120
TabIndex = 4
Top = 120
Width = 630
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "文件夹:"
Height = 180
Left = 120
TabIndex = 3
Top = 1320
Width = 630
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "驱动器:"
Height = 180
Left = 120
TabIndex = 2
Top = 600
Width = 630
End
End
Attribute VB_Name = "frmFilePath"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private strDrive As String
Public strFileName As String
Private Sub comdCancel_Click()
strFileName = ""
Hide
End Sub
Private Sub comdOK_Click()
strFileName = txtFileName
Hide
End Sub
Private Sub Drive1_Change()
On Error GoTo ERR
' 通过Dir1显示Drive1上的文件夹
Dir1.Path = Drive1.Drive
strDrive = Drive1.Drive
ChDrive Drive1.Drive
Exit Sub
ERR:
MsgBox "该驱动器内无数据可读", _
vbOKOnly + vbExclamation, "提示"
'若驱动器内无数据可读,则Drive1、Dir1返回原状态
Drive1.Drive = strDrive
Dir1.Path = strDrive
Resume Next
End Sub
Private Sub Dir1_Change()
'通过文件
列表框File1显示Dir1所选文件夹中的文件
File1.Path = Dir1.Path
ChDir Dir1.Path
End Sub
Private Sub Drive1_GotFocus()
strDrive = Drive1.Drive
End Sub
Private Sub File1_Click()
If Right(Dir1.Path, 1) = "\" Then
txtFileName = Dir1.Path & File1.FileName
Else
txtFileName = Dir1.Path & "\" & File1.FileName
End If
End Sub
Private Sub Form_Load()
File1.Pattern = "*.TXT"
End Sub