×

VB.Net Programs

VB.Net program to perform the LOGICAL OR operation using the OrElse operator

By Nidhi Last Updated : November 16, 2024

LOGICAL OR operation using the OrElse operator in VB.Net

Here, we will perform a logical "or" operation between two conditions, then we need to use the "OrElse" operator.

Note: In case of logical "or", if anyone operand is TRUE then it will return TRUE otherwise it will return FALSE.

VB.Net code to demonstrate the example of LOGICAL OR operation using the OrElse operator

The source code to perform the logical "or" operation using the "OrElse" operator is given below. The given program is compiled and executed successfully.

'VB.Net program to perform the logical 
'"or" operation using "OrElse" operator.

Module Module1

    Sub Main()

        Dim num1 As Integer = 6
        Dim num2 As Integer = 8

        If num1 = 6 OrElse num2 = 8 Then
            Console.Write("Hello")
        Else
            Console.Write("Hiiii")
        End If

        Console.ReadLine()
    End Sub

End Module

Output:

Hello

Explanation:

In the above program, we created a module Module1 that contains a function Main(). In the Main() function, we created two variables num1 and num2 that are initialized with 6 and 8 respectively.

If num1 = 6 OrElse num2 = 8 Then
    Console.Write("Hello")
Else
    Console.Write("Hiiii")
End If

In the above code, we compared the values of variable num1 and num2 for equality. After that perform the logical "or" operation between both conditions using the "OrElse" operator. That's why the "Hello" message will be printed on the console screen.

VB.Net Basic Programs »


Comments and Discussions!

Load comments ↻





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