Results 1 to 4 of 4

Thread: Files problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    10

    Unhappy

    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?

  2. #2
    Guest
    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


  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  4. #4
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    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
  •  



Click Here to Expand Forum to Full Width