1

Possible Duplicate:
VB.NET Function Return

If I have a function that returns a boolean, what is the difference between:

Return False

and

Function = False
2

2 Answers 2

3

Return False immediately exits the function so nothing further is executed.

Setting FunctionName = False allows the return value to be assigned again before the function exits.

Personally I'd stick with Return as it's much clearer what you're trying to do. Assigning to the function name is left over from VB6.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. So with Return False will the caller "see" the value "False"? In other words if I say If Function() = False Then do something will that work if I just Return False or do I have to set Function = False?
@JJD Yes, both ways will work like that.
0

the Return statement also exits the function. Assigning a value to the function name does not. Your function will keep executing until the end, so you could potentially change that value again.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.