+ Reply to Thread
Results 1 to 3 of 3

ReDim Array

  1. #1
    Viktor Ygdorff
    Guest

    ReDim Array

    I have an array that I use for many different things. Thus the size of the
    array may vary depending on the different tasks. I declare the array in a sub
    and then poulate the array with contents depending on an index number that
    has been sent to the sub. Code:

    Private arrayMaker(index As Integer)
    Dim array(1 to 100) As Variant
    if index = 0 then
    array(0) = "Interest rate"
    array(1)="Delta"
    rayy(2)=...etc.
    end if
    if index =1....etc..
    end if

    As you can see there is no point in setting one size for every array.
    Instead I want to ReDim the array depending on the number of inputs I use.
    How do you do this? Thanks!

  2. #2
    Tom Ogilvy
    Guest

    RE: ReDim Array

    Private arrayMaker(index As Integer)
    Dim varray() As Variant
    if index = 0 then
    redim varray(0 to 2)
    varray(0) = "Interest rate"
    varray(1)="Delta"
    varray(2)=...etc.
    end if
    if index =1....etc..
    Redim varray(0 to 10)
    end if

    .. . .
    End Sub

    --
    Regards,
    Tom Ogilvy


    "Viktor Ygdorff" wrote:

    > I have an array that I use for many different things. Thus the size of the
    > array may vary depending on the different tasks. I declare the array in a sub
    > and then poulate the array with contents depending on an index number that
    > has been sent to the sub. Code:
    >
    > Private arrayMaker(index As Integer)
    > Dim array(1 to 100) As Variant
    > if index = 0 then
    > array(0) = "Interest rate"
    > array(1)="Delta"
    > rayy(2)=...etc.
    > end if
    > if index =1....etc..
    > end if
    >
    > As you can see there is no point in setting one size for every array.
    > Instead I want to ReDim the array depending on the number of inputs I use.
    > How do you do this? Thanks!


  3. #3
    Viktor Ygdorff
    Guest

    RE: ReDim Array

    Great thanks! Is there any way of counting the input data so that if new info
    is to be added to the array you dont have to change the dimension but just
    add another line with the data? That would be very nice but your code works
    fine! Thank you ver much!

    "Tom Ogilvy" skrev:

    > Private arrayMaker(index As Integer)
    > Dim varray() As Variant
    > if index = 0 then
    > redim varray(0 to 2)
    > varray(0) = "Interest rate"
    > varray(1)="Delta"
    > varray(2)=...etc.
    > end if
    > if index =1....etc..
    > Redim varray(0 to 10)
    > end if
    >
    > . . .
    > End Sub
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Viktor Ygdorff" wrote:
    >
    > > I have an array that I use for many different things. Thus the size of the
    > > array may vary depending on the different tasks. I declare the array in a sub
    > > and then poulate the array with contents depending on an index number that
    > > has been sent to the sub. Code:
    > >
    > > Private arrayMaker(index As Integer)
    > > Dim array(1 to 100) As Variant
    > > if index = 0 then
    > > array(0) = "Interest rate"
    > > array(1)="Delta"
    > > rayy(2)=...etc.
    > > end if
    > > if index =1....etc..
    > > end if
    > >
    > > As you can see there is no point in setting one size for every array.
    > > Instead I want to ReDim the array depending on the number of inputs I use.
    > > How do you do this? Thanks!


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1