
Open TXT files in Visual Basic
Quote:
> Open "your_file.txt" For Input As #1
> Do Until Eof(1)
> Line Input #1, txt$
> Text1 = Text1 & txt$ & vbCrLf
> Loop
> Close #1
> You must set Text1.Multiline = True
Hi Joza...
This will give better performance....
Private Sub Command1_Click()
Dim iFile As Integer
iFile = FreeFile
Open "your_file.txt" For Input As iFile
Text1.Text = Input$(LOF(iFile), iFile)
Close #iFile
End Sub
.... also, .... the line below creates an entirely new buffer and replaces the entire
contents of the textbox each time it runs... you can speed your loop up (assuming you
still want to loop) by changing the line below...
Quote:
> Text1 = Text1 & txt$ & vbCrLf
...well, it's easier to show the whole thing so...
Private Sub Command1_Click()
Dim txt$
Open "c:\temp\clsSysController.cls.bak" For Input As #1
Text1.Text = ""
Do Until EOF(1)
Line Input #1, txt$
Text1.SelText = txt$ & vbCrLf
Loop
Close #1
End Sub
--
Ken Halter - MS-MVP-VB - http://www.mvps.org/vbsight - Please keep it in the groups..