VB中如何将filelistbox中列举的TXT打开,点击butten确定然后把内容显示到上一个窗口的TEXtBOX中
展开全部
Private Sub File1_Click()
'点击列表,读取TXT文件内容
'参考MSDN OPEN语句用法
Dim FileLine As String
'On Error Resume Next
Open File1.Path & File1.List(Index) For Input As #1
Do While Not EOF(1)
Line Input #1, FileLine
Text1.Text = Text1.Text & vbCrLf & FileLine
Loop
Close #1
End Sub
Private Sub Form_Load()
'Text1的MultiLine设置为True
'设置FILELISTBOX文件路径,文件类型
File1.Pattern = "*.txt"
File1.Path = "c:\"
Text1.Text = ""
End Sub
'点击列表,读取TXT文件内容
'参考MSDN OPEN语句用法
Dim FileLine As String
'On Error Resume Next
Open File1.Path & File1.List(Index) For Input As #1
Do While Not EOF(1)
Line Input #1, FileLine
Text1.Text = Text1.Text & vbCrLf & FileLine
Loop
Close #1
End Sub
Private Sub Form_Load()
'Text1的MultiLine设置为True
'设置FILELISTBOX文件路径,文件类型
File1.Pattern = "*.txt"
File1.Path = "c:\"
Text1.Text = ""
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询