One of the
hardest basic things that a C / C++
programmer has to get used to when working with
Visual Basic is the concept of
truth in VB is numerically equal to
-1. The reserved word "
True" is equal to -1, because of this, and can be a bit strange to work with at
first.
Therefore, a
statement like
if MyFunction(myArgs) Then
end if
...Would fail if your
program returns 1. It is a good
VB practice to always return True as if it were an atomic object, rather than the number -1. This flies in the face of
conventional programming, where -1 is oftentimes an error.
Correction: thanks to
yerricde* VB returns -1 because it is an integer with all it's bits as 1's. This is very useful for ANDing something against it.
I find myself sticking to
C conventions many times, and returning numbers from my
programs, even if it may not work as well. It is best to resign yourself to one
practice or the other, and not mixing the two.
Functions may fail unexpectedly, if you return 1, and not -1. Use the words
True and
False, and try not to do more than what it was designed to do; play by the
rules of the game, and you will
survive the ordeal.
* I guess you learn something new every day