vb6

Visual Basic 6 boolean inside while


In Visual Basic 6 the expression Not myList inside the While have what meaning? True or false?

myList = vbFalse

Do While Not myList

Solution

  • vbFalse is a numeric constant from the VBA.VbTriState enum that happens to equal to 0.
    0 is also the binary representation of the boolean constant False.

    The expression Not 0 negates all bits of 0 which turns it into -1.
    -1 is also the binary representation of the boolean constant True.

    So in a boolean context, such as in the While clause, the expression Not myList would be converted to True.

    But you should not be using vbFalse in the first place. You should be using False:

    myList = False
    
    Do While Not myList