user2386530
user2386530

Reputation: 23

VB6 Recursion and return variables in functions

This is a syntax question. I am confused as to when the "return variable" in a Function is used as a return variable or as a method call. For instance, if I have:

Function foo() As Boolean
     foo = True
     foo = foo And bar
End Function

Does the second line in this function act as a recursive call to foo, or does it resolve to true from the previous assignment?

Upvotes: 2

Views: 1054

Answers (1)

rskar
rskar

Reputation: 4657

To get the value as of the last assignment:

foo = foo And bar

To make a recursive call:

foo = foo() And bar

The () makes all the difference. (BTW, this applies to VBA too.)

Upvotes: 3

Related Questions