VB中如何将filelistbox中列举的TXT打开,点击butten确定然后把内容显示到上一个窗口的TEXtBOX中

2024-12-14 09:49:29
推荐回答(1个)
回答1:

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