Visual Basic has default properties that are sometimes implicitly called when evaluating an expression. However, I seem to of come across a discrepancy with this implicit execution of default properties. The project layout looks like:
Class1:
property test -> class2 (default)
Class2:
property test -> string "hello world" (default)
Form1:
Dim x As New Class2
MsgBox x
Debug.Print x
The MsgBox statement will implicitly call x's default (being test on class1) and further more it will call the default on that (being test on class2) which results in "hello world" being displayed on the screen. The Debug.Print statement does not do this however, and by following the debugger, it can be seen that only the first default (on class1) is being called.
I have verified that many of the built in functions such as MsgBox/RTrim/LTrim exhibit this behaviour, and that any self written methods or class methods do not do this; but am unable to work out why this occurs?