|
-
Oct 26th, 2004, 03:16 AM
#1
Thread Starter
Member
(RESOLVED) How to create a function that returns an array?
Apologies if this has been covered before, I am trying to create a function that will return an array - I'm not sure how to declare this.
If this is the declaration:
Private Function NameOfFunction(blablabla) As Double
I want "NameOfFunction" to be, say, a 10*10 array. Any suggestions would be great.
Another question too, after I'm done with this, can I just assign this to an array, like:
dim table(9,9) as Double
table=NameOfFunction
... or will I need to assign each element of the array separately?
Thank you!
Last edited by tassosp; Oct 26th, 2004 at 03:42 AM.
-
Oct 26th, 2004, 03:36 AM
#2
Fanatic Member
hi, here is a quick example of how to do return an array from a function. Note, you can't explicitly declare the size of the array the function will return.
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim arrTest() As Long
arrTest = ReturnArray
MsgBox arrTest(2, 2)
End Sub
Private Function ReturnArray() As Long()
Dim arrFNArray(5, 5) As Long
'put in value so we can see
arrFNArray(2, 2) = 66
ReturnArray = arrFNArray
End Function
-
Oct 26th, 2004, 03:41 AM
#3
Thread Starter
Member
Thank you ! - what I needed exactly! Saved me the pain of browsing through msdn!
Best wishes!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|