Results 1 to 3 of 3

Thread: Arrays

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2004
    Posts
    70

    Resolved Arrays

    Hi,

    I need to use an array such as

    Dim array() as string

    later on if I do:

    array(1)="john"

    says it doesn't work, I think it is because I have to initialize it. I've tried doing:

    Dim array() as string = {}

    but then when i try array(1)=... it says I'm out of bounds.

    How can I initialize an array with empty elements not knowing how many elements I will have (I could guess this if the other option is too complicated).

    Thanks in advance
    Last edited by nacho2; Dec 27th, 2004 at 03:12 PM.

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Arrays

    Use an arraylist, it will make your life much easier:

    VB Code:
    1. Dim j As New ArrayList
    2.         j.Add("John")
    3.         j.Add("Bill")
    4.  
    5.         MsgBox(j.Count)    'Returns 2
    6.  
    7.         MsgBox(j.Item(1))  'Returns "Bill" since arraylists are 0 based

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2004
    Posts
    70

    Re: Arrays

    alright thanks.

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