All function parameters are passed 'by reference' (unless you explicitly state ByVal in the param list).
This means that if you update a function parameter value in a function, the supplied value is changed permanently.
Therefore, one option is to simply add four parameters to your function.
Another option is to create a user-defined type, e.g.
Type MyType
Val1 as integer
Val2 as string
...
end type
then, you can declare your function to return a value of type MyType
function MyFunction(Param1 as integer, param2 as double) as mytype
....
dim RetVal as MyType
RetVal.Val1 = 100
RetVal.Val2 = "whatever"
....
MyFunction = RetVal
end function
another option might be to encode all the return values into a string and then decode them back out (which is often used with the openargs property of a form)
The most stylish answer would be to use the user-defined type. However, the context in which you use the function may limit your options.
Thanks for or response. I went with the function and it worked just fine! I was running on a paradigm that a function could return only one value. The call and function statements below allow for changes in all 4 variables passed.
I called the function from 2 forms but now can keep the common code in a single location for future maintenance. Four variables are passed to the function as noted in the call below.
Another aproach is (assuming all of hte retun values are typed the same) to return an array. Even the limitation of same type can be overcome by typing the return as Varriant, however this DOES incur a performance penalty, and may require explicit coercion to the desired data type within the calling object.
On the other side of the discussion, it SHOOULD be notewd that there is some 'coriosity' in wanting / needing a procedure whic returns different results to specific calling objects. On the surface, the different calling objects would appear to need to call seperate routines.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.