Results 1 to 3 of 3

Thread: Question On Array .

  1. #1

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    you have to ReDim the array to whatever size you need.

    Redim myArr(3)

  2. #2
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    You need to use ReDim (with Preserve to keep the old contents) first.

    VB Code:
    1. Redim Preserve array(1 to 10)

    The difference between this and Dim array(1 to 10) is that you can easily make this array bigger.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  3. #3
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    That's right, you need to ReDim / re-dimention the array and tell vb to add a new element before you can add the entry, this would make your code into :
    Code:
    Dim i as integer 
    dim strArray() as string
    
    i=0
    
    Do until i =3
        
        Redim Preserve strArray(i)
        strArray(i)="s"
    
        i=i+1
    
    loop
    The preserve part (as mentioned above) keeps your existing element entries, normally, using the ReDim statement on it's own would clear all of the prvious entries & wip the array first!

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

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