Results 1 to 6 of 6

Thread: General Question

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    México, D.F.
    Posts
    64

    Red face

    I'm learning VB, how can I declare and use arrays of variables.




    Thanx

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    There is more than one way.

    1st way - define top boundary
    Code:
    Dim vsMyStrings(5) as String
    
    vsMyStrings(0) = "First String"
    vsMyStrings(5) = "Last String"
    2nd way - define index ranges
    Code:
    Dim vsMyStrings(5 to 9) as String
    vsMyStrings(5) = "A string"
    vsMyStrings(9) = "Another string"
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Guest
    Code:
    Dim iArray(4) As Integer
    iArray(0) = 1
    iArray(1) = 2
    iArray(2) = 3
    iArray(3) = 4
    iArray(4) = 5
    'etc.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    México, D.F.
    Posts
    64

    Cool

    Thanx parksie

  5. #5
    Guest

    Thumbs up Also have a look at

    ReDim Preserve MyArray ..... way cool enhancement to vb5.

    Also you might like to have a look at multi-dimension arrays

    Code:
    Dim MyArray(4,4).
    
    For X = 0 to 4
       For Y = 0 to 4
          MyArray(X,Y) = whatever
       Next Y
    Next x
    Cool if you want to hold in memory something like a number of CDs with the tracks on each cd.

    Hope that gives you some more pointers

  6. #6
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    There is an array tutorial which goes into some detail on this site.

    http://www.vb-world.net/articles/arrays/

    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