![]() |
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. -- TheIrishThug ------------------------------------------------------------------------ TheIrishThug's Profile: http://www.excelforum.com/member.php...o&userid=29682 View this thread: http://www.excelforum.com/showthread...hreadid=495039 |
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 *** |
All times are GMT +1. The time now is 07:17 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com