Boolean variables


#1

This code assigns false to Label4.text. Didn’t it have to assign num to Label4.text? Is there any restriction or something to take care when you have boolean variables in your program?
By the way, lector is defined at top of the form as: Dim lector=False

Thanks in advance.
David.

If lector=False Or Not lector Then
  If tCodigo=0 Then Label4.text="num" 
Else
  Label4.text=lector 'debug
End If

#2

A couple of thoughts:

Given that you’ve set lector=False before the If statement is called, the Else statement would never be called because lector=False resolves to True and Not lector also resolves to True (a double-negative).

By chance is this code being called before Sub Main is called? Because Label4 isn’t available for updating until then.

Your code works here otherwise.

Kind regards,
Doug


#3

Thanks, Doug.

I found that the problema was that lector value is changed after reading an SQLite database. This Reading assings a “false” string value to lector, not a False boolean value as I expected. If I test for lector=“false” everything Works as I want.

Thanks again.
David.