×

VB.Net Programs

VB.Net program to perform the LOGICAL AND operation using the AndAlso operator

By Nidhi Last Updated : November 16, 2024

LOGICAL AND Operator using the AndAlso Operator in VB.Net

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

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

VB.Net code to demonstrate the example of LOGICAL AND Operator using the AndAlso Operator

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

'VB.Net program to perform the logical 
'"and" operation using "AndAlso" operator.

Module Module1

    Sub Main()

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

        If num1 = 6 AndAlso 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 AndAlso 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 and operation between both conditions using the "AndAlso" 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.