Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best way to return array from function

Status
Not open for further replies.

pullingteeth

Programmer
Sep 26, 2003
128
US
Say I have the function in a module:

Code:
private function getWords() as Variant
	dim words as String(10)
	...
	getWords = words
end function

Now say that I need to use the array in a ListResults function in a form; how would you best accomplish this?

I can't assign the getWords results to an array variable (array assignation not allowed, at least in Access 97), so therefore I need to convert it somehow, so that I can store it as a global variable:

Code:
words = TheModule.getWords
for each word in words
    ' build my global array incrementally
next word

This is obviously inefficient, though. Isn't there some way to cast, or directly convert, the results?

Thanks
 
Hi,
Code:
words = TheModule.getWords
for i = 0 to ubound(words, 1)
  x = words(i)
    ' build my global array incrementally
next


Skip,

[red]Be advised:[/red] [glasses]
Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top