This is correct, with the caveat that in VB, the function name can also be a variable that is returned. If you previously set it to true, it will return true.
More fully, in VB.Net, if I have a boolean function Foo() defined like this:
Public Function Foo() As Boolean '...
... the body of this function has an implied variable, also called Foo , which corresponds to the return type of the function - Boolean in this case, but Object if the return type is omitted (you should use Option Strict , which requires a return type). This implied variable is initialized to use the default value for this type.
If you cannot Return a value from a function, whether through an Exit Function or just reaching the end, this implied variable is returned instead. Therefore, the Boolean function returns False if you Exit Function earlier without making any other changes, because this is the default value in the implied variable used with this function. But you could also set this variable to True if you want, and then Exit Function will return True .
Nowadays, people often donβt use an implied variable, but there are situations when it can save you a few lines of code without any cost for clarity.
Joel Coehoorn
source share