驱动器列表框(DriveListBox控件)
Private Sub Command1_Click()
Dim i As Integer
Dim s As String
For i = 0 To Drive1.ListCount - 1
s = s & vbCrLf & Drive1.List(i)
Label2.Caption = s
Next i
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
目录列表框(DirListBox控件)
Private Sub Dir1_Change()
Label1.Caption = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
文件列表框(FileListBox控件)
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_Click()
If Right(File1.Path, 1) = "\" Then
Label1.Caption = "选择的文件的路径是: " & vbCrLf & File1.Path & File1.FileName
Else
Label1.Caption = "选择的文件的路径是: " & vbCrLf & File1.Path & "\" & File1.FileName
End If
End Sub
pathchange事件
Private Sub dir1_change()
File1.Path = Dir1.Path
End Sub
Private Sub drive1_change()
Dir1.pth = dirve1.dirve
End Sub
Private Sub file1_pathchange()
Label1.Caption = "路径为: " & File1.Path
End Sub
Private Sub form_load()
Label1.Caption = "路径为: " & Dir1.Path
End Sub
FileListBox(PatternChange事件)
Private Sub Combo1_click()
File1.Pattern = Combo1.Text
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
Label2.Caption = "文件的路径是: " & File1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_patternchange()
File1.Pattern = Combo1.Text
Label2.Caption = "文件的路径是: " & File1.Path
End Sub
Private Sub Form_Load()
File1.Path = Dir1.Path
File1.Pattern = Combo1.Text
Label2.Caption = "文件的路径是: " & File1.Path
End Sub
文件系统控件的联动
Private Sub Combo1_click()
File1.Pattern = Combo1.Text
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_Click()
Dim st As String, fpath As String
If Right(Dir1.Path, 1) = "\" Then
fpath = Dir1.Path & File1.FileName
Else
fpath = Dir1.Path & "\" & File1.FileName
End If
Text1.Text = ""
Open fpath For Input As #1
Do While Not EOF(1)
Line Input #1, st
Text1.Text = Text1.Text + st + vbCrLf
Loop
Close #1
End Sub
Private Sub File1_PatternChange()
File1.Pattern = Combo1.Text
End Sub
这篇博客详细介绍了VB编程中涉及的文件系统控件,包括驱动器列表框、目录列表框和文件列表框的使用,并探讨了PathChange及PatternChange事件,揭示了这些控件间的联动机制。
1324

被折叠的 条评论
为什么被折叠?



