How to return more than 1 variable?

Hello all.

Is it possible to return more than one variable? If so how?

return an array or a pair?

HI Dave,
Only one type can be set as a return type…

don’t understand?

[quote=450025:@Tim Seyfarth]HI Dave,
Only one type can be set as a return type…[/quote]

Which is why Dave is suggesting the one type hold more than one value. If you only need two, then a Pair is viable. Or an array of variants. Or a dictionary or JSONItem. Or an object that has multiple properties.

Anything that lets you return multiple values in that “one return value”. What works best for any given scenario depends on the scenario…

Pass in the return variables byref in the parameters of the function with a Boolean result of if the function worked.

you can use a class as return value and add as many variables as you like

Return a dictionary?

Depending on your needs, you can wrap the variables you want to return in

  • a class
  • a structure
  • a pair
  • a dictionary
  • an array

The return-value then is defined by the type of wrapper you used.

Or you use the methods parameters with ByRef.