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!

Can a function return more than one value ? 1

Status
Not open for further replies.

ZABADAK

Programmer
Feb 24, 2005
39
US
I have a report that prints monthly percentages and then a quarterly percentage.
I have a function that calculates the monthly percentages. I'd like this function to pass back not only the percentage but also the dividend and divisor for the calculation so that I can use these to form the quarterly percentage. Is this possible or is there a more elegant solution?
Each figure in the calculation is obtained by running a complex SQL query so I don't want to run each one more than once.
Thanks for any advice.
 
in your function you can send the other variables byRef.
Ex:
Private Function Example(Byref Divisor as long, byRef Dividend as long)
'code to find divisor and dividend
example=dividend/Divisor

end function

To go where no programmer has gone before.
 
You might try creating those additional variables when the report opens, then increment them each time the monthly ones are incremented, then calculate your quarterly result in the footer.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Hi,

Put each of the values in an array element and return the array.

Skip,

[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue]
 
Alternatively declare a new variable type:

Public Type Test
Val1 as Variant
Val2 as Variant
End Type

Public Funtion MyFunc() as Test
'...some code here

MyFunc.Val1=55
MyFunc.Val2=66

End Function

Ed Metcalfe.

Please do not feed the trolls.....
 


Ed,

I like that. Yet another way to skin a cat!

==> *

Skip,

[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top