Results 1 to 4 of 4

Thread: Dynamic Array Size??

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2004
    Posts
    2

    Dynamic Array Size??

    I have this program due on monday and i need to know how to dynmically create an array. Also i need to know how to determine the size of the dynamic array for my "while" loop

    The program reads from a space delimited text file and is suppose to count the occurrences of words in the file.

    Any suggestions?

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    You can either use an ArrayList (easier) or simply ReDim your Array each time it needs something added to it (but make sure you use the Preserve keyword).

  3. #3
    Addicted Member
    Join Date
    Apr 2002
    Location
    California
    Posts
    160
    Arrays are dynamic by default:

    VB Code:
    1. Dim arrString as string()
    2. ' or
    3. Dim arrString() as string
    4.  
    5. ' or
    6.  
    7. Dim arrString(10) as array
    8.  
    9. ' then
    10.  
    11. ReDim arrString(5) as array
    12.  
    13. Dim i as integer
    14.  
    15. For i = 0 to arrString.Length
    16. ' your code
    17. Next i
    Jason Moore

    Software Engineer, Database Architect, Web Designer

    (C#,VB/NET,ASP/NET,COLDFUSION,JAVASCRIPT,SQL)

    http://www.gatorstudios.com
    [email protected]

  4. #4
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by jwmoore2001
    Arrays are dynamic by default:
    Just remember this is only in VB. Most other languages, they are not.

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