View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] Tino@tino.com is offline
external usenet poster
 
Posts: 8
Default Opening a text file for input

Hi,

I do a lot of creating text files from Excel workbooks using "Open
blahblah for output as #1" and then printing to that file with "Print
#1, "etc"..

I now need to do some input from text files and don't know the syntax
& can't find it in HELP.

Specifically, I have a comma separated text file with an undefined
number of rows but always two fields.

What code would I need to achieve the following..

-Open a text file for reading
-Start a loop that will check line after line until the end of the
file
-Take both fields of a line of data (comma separated) and put each
field in a separate variable
-end the loop

I expect it would be something like this...(and I do know this does
nothing at the moment. I will be doing further manipulation of the
variables & dumping to another file later).

Open "c:\myfile.csv" for input as #1
Do while not EOF(myfile.csv)
read myfirstfield,mysecondfield
loop


Any help would be much appreciated.

Thanks.