问个vb读取文件路径的小问题

来源:百度知道 编辑:UC知道 时间:2024/06/23 02:40:36
我想用drivelistbox dirlistbox 和filelistbox这三个的路径组成一个路径来读取txt格式的文件,问下这三个的路径改怎么用? 我被那些引号都搞晕了
Open drive1.drive dir1.path file1.filename For Input As #1
这是没修改的代码,谁帮我把这个路径弄成正确的

Open Dir1.Path + "\" + File1.FileName For Input As #1

dim Fname1 As String

Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()
On Error GoTo e
Dir1.Path = Drive1.Drive
Exit Sub
e:
MsgBox "无法打开" & Drive1.Drive & "盘"
End Sub

'文件打开选择
Private Sub File1_Click()
On Error GoTo e
Fname1 = IIf(Right(Dir1.Path, 1) = "\", Dir1.Path, Dir1.Path & "\") & File1.FileName
e:
end sub

按照楼上的遇到根目录下的文件会有两个"\"

Open Dir1.Path & "\" & File1.FileName For Input As #1

不小得行不行,最好还是用个文件流!