I want to import a .txt file into a TextBox, how???
Open C:\text.txt For Input As #1
Line Input #1, Form1.Text1.Text
Close #1
Like that?
Thanks
Printable View
I want to import a .txt file into a TextBox, how???
Open C:\text.txt For Input As #1
Line Input #1, Form1.Text1.Text
Close #1
Like that?
Thanks
Code:Dim Line As String
Open C:\text.txt For Input As #1
Do
Line Input #1, Line
Form1.Text1.Text = Form1.Text1.Text & vbcrlf & Line
Loop Until EOF(1)
Close #1
Uhm, actually oetje, that code didnt work when there were lines in the text file.
I.e.
Blah1Blah1Blah1
Blah2Blah2Blah2
Would be displayed as:
Blah1Blah1Blah1||Blah2Blah2Blah2
Set the Text Box's Multiline property to True.
Code:'read the complete file instead of line by line
'faster and cleaner
Option Explicit
Private Sub Command1_Click()
Dim sfile As String, intNum As Integer
intNum = FreeFile
sfile = "C:\my Documents\myfile.txt"
Open sfile For Input As intNum
Text1 = StrConv(InputB(LOF(intNum), intNum), vbUnicode)
Close intNum
End Sub
Code:Open "MyFile.txt" For Input As #1
Text1 = Input(LOF(1), 1)
Close #1