-
April 10th, 2012, 04:02 PM
#1
populate array from txt
I loop txt file line by line with the simple free file do while eof ...loop ecc...
From each line in txt file i get 5 value and assign it to var1, var2, var3, ...var5.
I need to populate an array with value of each line until eof is true, how to?
-
April 10th, 2012, 05:54 PM
#2
Re: populate array from txt
Your question is rather unspecific.
The best I could evaluate out of your description is this.
As you do not seem to know how many lines there are in the file, you need a dynamic array.
Next, each line in the file holds 5 values.
The question is: Do you want to store each value in an individual array?
It is not clear what you want to do.
So you could do this:
Code:
Dim f%, n%, L$()
f = FreeFile
Open FileName For Input as #f
While not EoF(f)
redim preserve L(n)
Line Input #f, L(n)
n = n + 1
Wend
Close #f
FreeFile f
Now you have read all lines of the file.
What you ever want to achieve with the individual lines is up to you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|