×

VB.Net Programs

VB.Net program to demonstrate the BITWISE NOT operator

By Nidhi Last Updated : November 11, 2024

BITWISE NOT Operator in VB.Net

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

VB.Net code to demonstrate the example of BITWISE NOT Operator

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

'VB.Net program to demonstrate the 
'"bitwise NOT" operator.

Module Module1

    Sub Main()

        Dim num As Integer = 6

        If Not (num = 6) Then
            Console.Write("Hello")
        Else
            Console.Write("Hiiii")
        End If

        Console.ReadLine()
    End Sub

End Module

Output:

Hiiii

Explanation:

In the above program, we created a module Module1 that contains a function Main(). In the Main() function, we created a variable num with an initial value of 6.

If Not (num = 6) Then
    Console.Write("Hello")
Else
    Console.Write("Hiiii")
End If

In the above code, we compare the value of variable num with 6 for equality that will return TRUE, but because of the bitwise NOT operator it will because FALSE, and then the Else part will be executed and print "Hiiii" message on the console screen.

VB.Net Basic Programs »


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.