I need to read data from text files and use the same in my application. Im using VB 6.0. What commands do I use? Some Sample code would be highly appreciated.
Here's how to read an entire text file into a string - from the VB6 manual.
Function FileToString(strFilename As String) As String
iFile = FreeFile
Open strFilename For Input As #iFile
FileToString = StrConv(InputB(LOF(iFile), iFile), vbUnicode)
Close #iFile
End Function
A full tutorial and sample code can be found here
Open Filename$ For Input As #FileHandle
Do While Not EOF(FileHandle) ' Loop until end of file
Line Input #FileHandle, TextLine$ ' Read line into variable
' Your code here
Loop
Close #FileHandle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With