Thread: File I/O
View Single Post
 
Old 04-17-2013, 02:18 PM
Gruff's Avatar
Gruff Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default Reading Full Lines from a Text File

Reading Full Lines from a Text File

I thought is might be a good idea to add a sub section
on reading full lines of text from a text file serially.

You open a text file for input as you would in GavinO's excellent basic File IO tutorial and use the 'Line Input' statement in a loop.

Code:
Open FileName for Input as <Filenumber> Do While Not EOF(<FileNumber>) Line Input <FileNumber>, <String Variable> ' Process <String Variable> Loop Close

The entire line of text upto but not including the NewLine Characters is returned.
If you want the NewLine characters in the string variable you will have to add them yourself.

Code:
Dim sHold as string Open FileName for Input as <Filenumber> Do While Not EOF(<FileNumber>) Line Input <FileNumber>, sHold TextBox.text = TextBox.Text & sHold & vbCrLf Loop Close
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote