Results 1 to 4 of 4

Thread: I would like to announce that I am an idiot

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    83
    I didn't know what arrays are pathetic eh?

    now for a small question

    Can you say all array values are x without doing a for/next loop(or similar)?
    Ian Callanan
    VB6.0
    [email protected]

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    I'm unsure if I understand your problem... so I'll try tp explain what arrays are:

    Definition
    An array is a collection of values of the same type

    Usage
    You need an array where ever you have to do something for more than 1 variable coz you can use a loop then. For example if you make a game and you want to move enemies, without arrays you'd have to do something like this:
    Code:
    Dim Enemy1
    Dim Enemy2
    Dim Enemy3
    ...
    Enemy1.Move
    Enemy2.Move
    Enemy3.Move
    If you instead use an array you can replace much code:
    Code:
    Dim Enemy(5)
    ...
    Dim A as Long
    
    For A = 0 to 5
       Enemy(A).Move
    Next
    See the difference? Another good thing is that you can change the size of an array at runtime:
    Code:
    Dim A() as long
    
    ReDim A(10) 'Set a size
    ReDim Preserve A(20) 'Make it bigger
    ReDim Preserve A(5) 'and smaller...
    (While preserve means that A does not lose the values already contained when resizing)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    83
    well each value in an array can be different(yet similar)(god i hope im right on that )

    but what if you want all the values in an array to be the same like myarray(1) = 5 myarray(2) = 5....etc
    Ian Callanan
    VB6.0
    [email protected]

  4. #4
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Lightbulb

    Assume MyArray() size is 5 then you can do this way.

    Code:
    Dim A As integer
    For A = 0 to 4: MyArray(A) = 5:Next

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