Functions return some data and an indication of the function’s success

It is quite common to use the return value of a function to return True, False, or perhaps an error code. The actual data value is returned as a parameter by reference. For example, consider this code fragment:

bRet = GetFileVersion(ByRef nVersion, filename)

Here the version of filename is returned by reference, provided the file was found correctly. If the file was not found, the function will return False and nVersion will not be accurate.

You have a couple of alternatives.

nVersion = GetFileVersion(filename)

If IsError(nVersion) Then
    ' nVersion is unreliable; take some action...
Else
    ' nVersion is reliable; use it...
End if

Error raising and trapping is not to everyone’s taste, so the second option might have some appeal for you.