Home »
VB.Net »
VB.Net Programs
VB.Net program to perform BITWISE AND operation
By Nidhi Last Updated : November 16, 2024
BITWISE AND Operator in VB.Net
Here, we will perform a BITWISE AND operation between two integer variables and print the result.
VB.Net code to demonstrate the example of BITWISE AND Operator
The source code to perform BITWISE AND operation is given below. The given program is compiled and executed successfully.
'VB.Net program to perform "BITWISE AND" operation.
Module Module1
Sub Main()
Dim num1 As Integer = 3
Dim num2 As Integer = 2
Dim res As Integer = 0
res = num1 And num2
Console.WriteLine("Result: " + res)
Console.ReadLine()
End Sub
End Module
Output:
Result: 2
Explanation:
In the above program, we created a module Module1 that contains a function Main(). In the Main() function, we created three local variables num1, num2, and res that are initialized with 3, 2, and 0 respectively.
res = num1 And num2
Now evaluate the above expression.
res = num1 And num2
res = 3 And 2
The binary equivalent of 3 is 11.
The binary equivalent of 2 is 10.
Then
11
10
====
10
That is 2.
At last, we printed the value of res on the console screen.
VB.Net Basic Programs »