-
Hello
I need to open a text file and take its contents to an array,how can I do that?
and how do I know how many rows and cols have the file?
this to make a couple of cicles and read 1 by 1 the cols and the rows
using C its something like this:
for(rows=0;array(rows)(0)!='\0';rows++)
for(cols=0;array(rows)(cols)!='\0';cols++)
but in VB?
-
is your textfile delimited or fixed length? if it is delimeted, you can use the 'Split' function to find out the cols. it is not that important to find out the rows, you can use 'ReDim' dimension you Array dynamically.
hope that helps
-
I'm considering you shoud open your file in binary instead and then split up it into an array
-
When you say "array" you seem to be saying 2d array, with one word per cell? one character per cell?
A simple way (not too efficient but fast is use the split function as mentioned above.
-split the text into lines vbcrlf (this dynamically creates the rows array)
-and for the column width do a search to get the largest number of words in a row and and split the lines into words with " ".
you'd need to link a UDT to the first array for this to work.
the question was very vague though so I might be on the wrong track
cheers