|
-
May 13th, 2000, 05:56 PM
#1
Thread Starter
New Member
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?
-
May 13th, 2000, 07:08 PM
#2
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
-
May 13th, 2000, 07:10 PM
#3
transcendental analytic
I'm considering you shoud open your file in binary instead and then split up it into an array
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 13th, 2000, 09:58 PM
#4
Fanatic Member
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
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
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
|