Returning Values
Function return values should usually be held in a temporary variable and then assigned to the function variable at the end of the routine.
This has two benefits.
The code is not specific to the name of the function so portability is aided when cutting and pasting part of the function code elsewhere;
also the value of the function variable may be used in calculations, otherwise a recursive call would be generated.
Private Function DoSomething(ByVal iMyValue as Integer) as Single
Dim sgReturnValue as Single
' Set default value
sngRetVal = 0
<code block>
' Set the Function value
DoSomething = sgReturnValue
End Function
Returning Strings
Returning Objects
You need to use Set
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext