Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Visual Basic 6 convert integers to booleans?

I am reading the following code in vb6

If someInteger Then
    DoSomething
End If

I don't know if it means

  1. someInteger == 1,
  2. someInteger > -1,
  3. someInteger > 0 or
  4. Convert.ToBoolean(someInteger)

What's the equivalent expression in C#?

like image 647
Jader Dias Avatar asked Jul 19 '26 21:07

Jader Dias


1 Answers

In VB6 any non-zero value is considered True; zero is false. I would advice to always specify the expression as it was (and it should be) boolean:

If someInteger <> 0 Then ...
like image 66
vulkanino Avatar answered Jul 24 '26 03:07

vulkanino