What are the Integer values of Boolean False and True in VB6?

前端 未结 3 791
南方客
南方客 2020-12-19 01:52

I\'m working with a bit of old VB6 code that goes thus...

Dim STATUS As Integer

STATUS = -1

If (Not STATUS) Then
\' do something
Else
\' do something else
         


        
3条回答
  •  [愿得一人]
    2020-12-19 02:20

    In VB 6, True has a numeric value of -1. False has a numeric value of 0.

    The reason for this is because the Boolean data type is stored as a 16-bit signed integer. Therefore,
    -1 evaluates to 16 1s in binary (1111111111111111). False is 16 0s (0000000000000000). This produces the relationship that has held throughout the evolution of BASIC: True = Not False.

提交回复
热议问题