Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading a text file with MS VB breaks on a ",".

Status
Not open for further replies.

Sanibel

Technical User
Nov 15, 2001
73
GB
I am trying to read a free text file from a module using the following code

intHandle=FreeFile()
strFilename="Filename"
Open strFilename For Input As #intHandle
Do While Not EOF(intHandle)
Input #intHandle, strLine
etc

but each input statement seems to break on a comma not at the end of a line. I have used similar code in the past to read in the complete line of a text file, but looking back at these examples I see that the text file contained no commas. Does VB force a line break on a comma and if so is there a parameter or a different read command I can use to read in the complete line.

Thanks
 

You could try OpenAsTextStream Method of the Scripting FileSystemObject library to open the file, and read it line by line

 
Try:

Code:
intHandle=FreeFile()
strFilename="Filename"
Open strFilename For Input As #intHandle  

Do While Not EOF(intHandle)
   Line Input #intHandle, strLine 
   'Some other code here
Loop

Ed Metcalfe.

Please do not feed the trolls.....
 
[!]Line [/!]Input #intHandle, strLine

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top