Results 1 to 2 of 2

Thread: Stupid question about Array!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2002
    Posts
    29

    Stupid question about Array!

    Hi,

    ** That's a dummy question for you, expert **

    I try to declare and work with an array that I don't know the size he will have during my process.

    I don't use often Array so my notion about it are very limited.

    Someone get a clue to how to proceed?

    Thanx

  2. #2
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456

    Re: Stupid question about Array!

    Originally posted by John9
    Hi,

    ** That's a dummy question for you, expert **

    I try to declare and work with an array that I don't know the size he will have during my process.

    I don't use often Array so my notion about it are very limited.

    Someone get a clue to how to proceed?

    Thanx
    Create a dynamic array !!

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4. Dim lstrArray() As String
    5.  
    6.    ReDim lstrArray(0)
    7.  
    8.    lstrArray(UBound(lstrArray)) = "A"
    9.  
    10.    ReDim Preserve lstrArray(UBound(lstrArray) + 1)
    11.  
    12.    lstrArray(UBound(lstrArray)) = "B"
    13.  
    14.    ReDim Preserve lstrArray(UBound(lstrArray) + 1)
    15.  
    16.    lstrArray(UBound(lstrArray)) = "C"
    17.  
    18. Dim i As Integer
    19.    
    20.     For i = LBound(lstrArray) To UBound(lstrArray)
    21.         MsgBox lstrArray(i)
    22.     Next
    23.    
    24. End Sub

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