|
|
Subject:
Excel VB - Input Line with OSX text file
Category: Computers > Programming Asked by: les9999-ga List Price: $10.00 |
Posted:
19 Apr 2005 14:27 PDT
Expires: 21 Apr 2005 22:04 PDT Question ID: 511520 |
OS-X uses a different end of line character in text files than Windows or OS-9. Because of this the input line command in Excel VB gets the entire file rather than one line at a time. Is there a solution for this? |
|
There is no answer at this time. |
|
Subject:
Re: Excel VB - Input Line with OSX text file
From: justabum-ga on 21 Apr 2005 14:22 PDT |
There are a few easy solutions to this. Here is one. 1) Read in entire file as you are doing to one variable 2) Use the "split" function to convert the string to an array. I believe the EOL marker in OS-X is chr(13); therefore your command will look something like myArray = split(myFile, chr(13)) 3) loop through the array, each item being a line. i.e. for i = 0 to ubound(myArray) process(myArray(i)) next |
Subject:
Re: Excel VB - Input Line with OSX text file
From: les9999-ga on 21 Apr 2005 15:15 PDT |
When trying this approach I get the message compile error "Can't assign to array". My code looks like: dim myarray(1 to 3000) as string dim myfile as string open "file.txt" for input as #1 input line #1, myfile myarray = split(myfile,chr(13)) ... ... Any additional suggestions? Thanks, |
Subject:
Re: Excel VB - Input Line with OSX text file
From: les9999-ga on 21 Apr 2005 22:04 PDT |
I see how it works now. You can't specify the array limit. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |