Results 1 to 2 of 2

Thread: tips array and collection

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2012
    Posts
    1

    tips array and collection

    Hello,
    I need a piece of advice on a problem that I have.
    I read a list of numbers from a txt file, this list changes over time.
    For each number of this list (I don't' know how many they are, they can be 10 or 200) I have to create a new array where I have to put inside other values. I don't want to use a muldimensional array because I have to to know often how many values I have in each array and add o remove new values inside of it. I have thought to use the collection, but i'have read that are slow.

    How can I declare the arrays without know how many I need?

    Thanks in advance for the answer.

    Claudio.

  2. #2
    Hyperactive Member Lenggries's Avatar
    Join Date
    Sep 2009
    Posts
    353

    Re: tips array and collection

    A couple of ways come to mind. The most flexible method is to define a custom class. But a shortcut might be to just declare a custom type:
    Code:
    Private Type Foo
       ID As Long
       Data() As Long
    End Type
    
    Private m_Array() As Foo
    
    .....
    
    Private Sub FooThis()
       Dim i As Long
       ReDim m_Array(SomeNumber)
    
       For i = 0 To UBound(m_Array)
          ReDim m_Array(i).Data(SomeOtherNumber)
       Next i
    End Sub
    It's quick (to code), but dirty

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