Home »
VB.Net »
VB.Net Programs
VB.Net program to perform BITWISE OR operation
By Nidhi Last Updated : November 16, 2024
BITWISE OR Operator in VB.Net
Here, we will perform a BITWISE OR operation between two integer variables and print the result.
VB.Net code to demonstrate the example of BITWISE OR Operator
The source code to perform BITWISE OR operation is given below. The given program is compiled and executed successfully.
'VB.Net program to perform "BITWISE OR" operation.
Module Module1
Sub Main()
Dim num1 As Integer = 5
Dim num2 As Integer = 2
Dim res As Integer = 0
res = num1 Or num2
Console.WriteLine("Result: {0}", res)
Console.ReadLine()
End Sub
End Module
Output:
Result: 7
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 5, 2, and 0 respectively.
res = num1 Or num2
Now evaluate the above expression.
res = num1 Or num2
res = 5 Or 2
The binary equivalent of 5 is 101.
The binary equivalent of 2 is 010.
Then
101
010
====
111
That is 7.
At last, we printed the value of res on the console screen.
VB.Net Basic Programs »