J
Jay
In a VBA function, a value is returned by assigning the function name
to the value. Can this be done in several places (CODE EXAMPLE 1), or
should it only be done once at the end of the function, with a
variable being used to temporarily hold the return value (CODE EXAMPLE
2)?
CODE EXAMPLE 1
Function Test() as integer
Test = 0
If ??? then
Test = 1
Exit Function
End if
...
End Function
CODE EXAMPLE 2
Function Test() as integer
Dim ReturnVal as integer
ReturnVal = 0
If ??? then
ReturnVal = 1
Goto EndFunc
End if
...
EndFunc:
Test = ReturnVal
End Function
to the value. Can this be done in several places (CODE EXAMPLE 1), or
should it only be done once at the end of the function, with a
variable being used to temporarily hold the return value (CODE EXAMPLE
2)?
CODE EXAMPLE 1
Function Test() as integer
Test = 0
If ??? then
Test = 1
Exit Function
End if
...
End Function
CODE EXAMPLE 2
Function Test() as integer
Dim ReturnVal as integer
ReturnVal = 0
If ??? then
ReturnVal = 1
Goto EndFunc
End if
...
EndFunc:
Test = ReturnVal
End Function