#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Avg Arrays PAL Excel Worksheet Functions 2 February 13th 09 06:02 PM
About Arrays hke[_23_] Excel Programming 2 November 17th 04 01:29 PM
arrays again RobcPettit Excel Programming 3 January 24th 04 10:33 PM
Arrays David Excel Programming 5 January 10th 04 05:09 AM
ARRAYS Gary B[_3_] Excel Programming 8 July 14th 03 03:59 AM


All times are GMT +1. The time now is 09:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"