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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

return multiple values from a subprocedure/function

Status
Not open for further replies.

MrsMope

Technical User
Oct 18, 2004
125
US
Is it possible to return multiple values from a subprocedure or function?
 
You can return multiple values in the form of an array, a collection, or a dictionary. So, no you cannot return multiple values but you can return a single object that contains multiple values.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Well ...

You can declare arguments ByRef and then any value assigned to them in the called procedure will be passed back to the calling procedure. Just be sure to code those arguments as variables rather than constants in the call to the procedure.
 
Golom,
can you give me an example of how that call would look?

here is my calling statement and procedure heading:

Code:
strList = FillCombo(cboFromDate.Value, cboToDate.Value, cboSalesperson.Column(0), 1, _
'                            intOption, fraBusType.Value)

Code:
Public Function FillCombo(FromDate As Date, ToDate As Date, DecNum As String, _
                            intPage As Integer, intOption As Integer, _
                            Optional intBusType As Integer, Optional ICRoles As String)
 
Something like this
Code:
Public Function FillCombo( _
[COLOR=blue]ByRef[/color] FromDate As Date, _
[COLOR=blue]ByRef[/color] ToDate As Date, _
[COLOR=blue]ByRef[/color] DecNum As String, _
[COLOR=blue]ByRef[/color] intPage As Integer, _
[COLOR=blue]ByRef[/color] intOption As Integer, _
Optional intBusType As Integer, _
Optional ICRoles As String)
If, in this routine, you were to

FromDate = #01/01/2005#

then cboFromDate.Value would have that value on return from the routine.

You would not want to set IntPage because you are calling that with a constant value (not a variable). That can cause you all sorts of problems.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top