Reading files in Visual Basic, GW-Basic style
April 6, 2004 on 3:26 pm | In General |Recently, someone asked me how to quickly read a file with Visual Basic code without dealing with streams.
Of course, once you learn doing this in GW-Basic, Basica, and friends, it sticks in your mind. Those who forgot, shame on you!
Dim iFileNumber As Integer
Dim sLine As String
iFileNumber = FreeFile
Open "C:stats.log" For Input As iFileNumber
Do While Not EOF(iFileNumber)
Input #iFileNumber, sLine
MsgBox sLine
Loop
Related Posts:
- Validating a Date Field with RIFE
- How to Format Dates for SQL in Java
- Rapid web development
- Copy/paste command-line utilities
2 Comments »
RSS feed for comments on this post.
Leave a comment
Powered by blog.mu with Pool theme design by Borja Fernandez.


If you are wanting to read a whole line (up to the next cr/lf pair), ammend your code to:
Line Input #iFileNumber, sLine
Input by itself is used to read comma seperated values in the order they were written:
Print #iFileNumber, 1, “A test”
Input #iFileNumber, iMyInt, sMyString
Hope this helps :-)
Comment by Richard@Home — 8 April 2004 #
Of course! :-)
Comment by Eddy Young — 8 April 2004 #