-
using fso I can read a file into a textbox like soText1.Text = Input(LOF(1), 1)
if I want to read a complete text file
and store it in a var how is it done
in regular read vb looks for a #(FileNumber)
so it won't accept myVar = input(lof(Filenumber),myVar)
-
Open your file with a filenumber first then
Code:
filenumber=freefile
Open yourfile for binary as filenumber
...your code
close filenumber
-
doesn't accept this
input(lof(Filenumber),myVar)
how do I read the entire file inot myVar
-
Hmmm, well you can do it this way
Code:
Property Get File(Filename As String) As String
Dim fnum As Byte
fnum = FreeFile
Open Filename For Binary As fnum
File = Space(LOF(fnum))
Get #fnum, , File
Close fnum
End Property
-
Use the following function:
Code:
Open "C:\MyFile.txt" For Input As #1
Do Until EOF(1)
Line Input #1, tString
Text1.Text = Text1.Text & tString
Loop
Close #1