(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Boolean value calculation: Or, Xor, And, Not
public class Test
public Shared Sub Main
Dim B As Boolean
B = False Or True
Console.WriteLine(B)
B = False Xor False
Console.WriteLine(B)
B = False And True
Console.WriteLine(B)
B = Not True
Console.WriteLine(B)
End Sub
End class
True
False
False
False
CBool(0): convert 0 to Boolean
Module Tester
Public Sub Main()
Dim iBoolean As Integer = -1
Dim bBoolean As Boolean = CBool(iBoolean)
bBoolean = CBool(0)
Console.WriteLine("Boolean of 0 is {0}", bBoolean)
End Sub
End Module
Boolean of 0 is False
CBool: convert Integer to Boolean
Module Tester
Public Sub Main()
Dim iBoolean As Integer = -1
Dim bBoolean As Boolean = CBool(iBoolean)
Console.WriteLine("Boolean of {0} is {1}", iBoolean, bBoolean)
End Sub
End Module
Boolean of -1 is True
Define Boolean value and use it in If statement
public class Test
public Shared Sub Main
Dim blnStatus As Boolean = True
Console.WriteLine(blnStatus)
blnStatus = Not blnStatus
Console.WriteLine(blnStatus)
If blnStatus Then
Console.WriteLine("The status is true.")
Else
Console.WriteLine("The status is false.")
End If
End Sub
End class
True
False
The status is false.