急!如何VB文件列表框双击文件名在文本框中显示文件内容?

[复制链接]
查看11 | 回复1 | 2009-6-6 23:00:06 | 显示全部楼层 |阅读模式
如题,我在窗口中设置了驱动器列表框、目录列表框和组合框分别选择盘符、路径、文件类型(TXT或VBP,均为文本文件),在文件列表框中双击文件名时打开此文件并将内容显示在文本框中。
如何?
急!!!!解决了我还会追加悬赏分的!!!各位帮帮忙
我的部分代码如下:
Private Sub Form_Load()
Combo1.AddItem "文本文件(*.TXT)"
Combo1.AddItem "VBP文件(*.VBP)"
Combo1.Text = Combo1.List(0)
File1.Pattern = "*.TXT"
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Combo1_Click()
Select Case Combo1.ListIndex
Case 0

File1.Pattern = "*.txt"
Case 1

File1.Pattern = "*.vbp"
End Select
End Sub
Private Sub file_click()
If Right(File1.Path, 1) = "\" Then
fName = File1.Path + File1.FileName
Else
fName = File1.Path + "\" + File1.FileName
End If
Text1.Text = fName
End Sub
Private Sub file_dblclick()
Dim s$
If Right(File1.Path, 1) = "\" Then
fName = File1.Path + File1.FileName
Else
fName = File1.Path + "\" + File1.FileName
End If
Text1.Text = fName
'App.Path = fName
'Open App.Path For Append As #1
'Do While EOF(1)
'Line Input #1, s
'Text1.Text = Text1.Text & s
'Loop
'Close #1
End Sub


回复

使用道具 举报

千问 | 2009-6-6 23:00:06 | 显示全部楼层
修改file_dblclick如下Private Sub file_dblclick()Dim s$If Right(File1.Path, 1) = "\" ThenfName = File1.Path + File1.FileNameElsefName = File1.Path + "\" + File1.FileNameEnd IfText1.Text = fNameText1.MultiLine = TrueOpen fName For input As #1Do until EOF(1)Line Input #1, sText1.Text = Text1.Text & chr(1...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行