Home >>VB.Net Programs >VB.Net program to demonstrate the BITWISE NOT operator

VB.Net program to demonstrate the BITWISE NOT operator

Write a VB.Net program to demonstrate the BITWISE NOT operator

Here, to reverse the result of conditions used in the program, we will use the BITWISE NOT operator.

Program

The source code to show the operator of BITWISE NOT is given below. The program given is compiled and successfully executed.

Example


Module Module1
    Sub Main()
        Dim num As Integer = 10
        If Not (num = 10) Then
            Console.Write("Hello")
        Else
            Console.Write("phptpoint")
        End If
        Console.ReadLine()
    End Sub
End Module

Output:
phptpoint

Explanation:

We generated a Module1 module in the above program that contains the function Main(). We generated a variable num with an initial value of 10 in the Main() function.

If Not (num = 10) Then
    Console.Write("Hello")
Else
    Console.Write("phptpont")
End If

In the above code, for equality, we compare the value of variable num with 10 that returns TRUE, but because of the bitwise NOT operator, it will cause FALSE, and then the Else part will be executed and the console screen will print phptpoint.


No Sidebar ads