Can a function return two values?
Here is an example
Function GE()
Dim a As Long
Dim station As Long, offset As Long
station = 1
offset = 2
a = 3
Call ff(a, station, offset)
MsgBox station & ", " & offset
GE = elevation(station, offset)
MsgBox GE
End Function
Function ff(var As Long, ByRef station As Long, ByRef offset As Long)
station = var + 1
offset = var ^ 2 + 1
End Function
Function elevation(station As Long, offset As Long)
elevation = station + offset
End Function
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Anil K." wrote in message
...
Is it possible for a function to return two values to be
used in another function?
Suppose I need a function "ff" to calculate two variables
called "station" and "offset". Is it possible to return
both these variables to be used in another function
called "elevation(station, offset)"?
A very rough algorithm follows -
Function GE()
'This is the main function
Dim a as long
Call ff(a)
GE = elevation(station, offset)
End Function
Function ff( var as long)
'Returns station and offset to the main function
station = a +1
offset = a^2+1
'How do I return both station and offset?
??
End Function
Function elevation (station as long, offset as long)
elevation = station + offset (for simplicity)
End Function
THANKS IN ADVANCE.
|