急!如何VB文件列表框双击文件名在文本框中显示文件内容?
如题,我在窗口中设置了驱动器列表框、目录列表框和组合框分别选择盘符、路径、文件类型(TXT或VBP,均为文本文件),在文件列表框中双击文件名时打开此文件并将内容显示在文本...
如题,我在窗口中设置了驱动器列表框、目录列表框和组合框分别选择盘符、路径、文件类型(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
快,被采纳还会追加分数,各位大哥,快帮忙 展开
如何?
我的部分代码如下:
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
快,被采纳还会追加分数,各位大哥,快帮忙 展开
3个回答
展开全部
修改file_dblclick如下禅悔
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
Text1.MultiLine = True
Open fName For input As #1
Do until EOF(1)
Line Input #1, s
Text1.Text = Text1.Text & chr(13) & chr(10) & s
Loop
Close #1
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
Text1.MultiLine = True
Open fName For input As #1
Do until EOF(1)
Line Input #1, s
Text1.Text = Text1.Text & chr(13) & chr(10) & s
Loop
Close #1
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
App.Path是桐喊对象无法赋值睁咐
Open fName For Append As #1
Do While Not EOF(1)
Line Input #1, s
Text1.Text = Text1.Text & s
Loop
Close #1
试一试吧局早野
Open fName For Append As #1
Do While Not EOF(1)
Line Input #1, s
Text1.Text = Text1.Text & s
Loop
Close #1
试一试吧局早野
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
'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
App.Path能渗胡孙赋值吗做扮?换丛链个变量吧
'Open App.Path For Append As #1
'Do While EOF(1)
'Line Input #1, s
'Text1.Text = Text1.Text & s
'Loop
'Close #1
App.Path能渗胡孙赋值吗做扮?换丛链个变量吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询