+ Reply to Thread
Results 1 to 2 of 2

arrays

  1. #1
    Registered User
    Join Date
    12-15-2005
    Posts
    23

    arrays

    i have a function that returns an array. how do i need the Dim the variable so that vba will allow me to have Variable = FunctionReturningArray
    leaving the variable as a variant works, but hogs memory.
    i tried "dim variable(0 to 5) as string", but this does not work.

  2. #2
    Edward Ulle
    Guest

    Re: arrays

    Since parameters are passed to subroutines and functions by reference
    you can simply pass the array as parameter. I believe this will work
    for any data type.

    See the following example.

    Option Explicit

    Sub Test()

    Dim dblArray(5) As Double

    PopulateArray dblArray

    MsgBox dblArray(2)

    End Sub

    Private Function PopulateArray(inArray() As Double)

    Dim i As Integer
    Dim x As Double

    x = 1#
    For i = 0 To 5
    inArray(i) = x
    x = x + 1#
    Next

    End Function




    *** Sent via Developersdex http://www.developersdex.com ***

+ 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