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

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

Write a VB.Net program to perform the LOGICAL AND operation

Here, between two conditions, we will perform the logical and operation, then we must use the operator of AndAlso.

Note : In the case of logical "and", if both operands are TRUE then it will return TRUE otherwise it will return FALSE.

Program

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

Example


Module Module1
    Sub Main()
        Dim num1 As Integer = 10
        Dim num2 As Integer = 11
        If num1 = 10 AndAlso num2 = 11 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 two variables num1 and num2 in the Main() function that are initialized with 10 and 11 respectively.

If num1 = 10 AndAlso num2 = 11 Then
    Console.Write("Hello")
Else
    Console.Write("phptpoint")
End If

We compared the num1 and num2 variable values for equality in the above code. After that, use the "AndAlso" operator to perform the logic and operation between both conditions. That's why the message 'Hello' will be written on the screen of the console.


No Sidebar ads