ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

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

Here, we are going to learn how to perform the LOGICAL AND operation using the AndAlso operator in VB.Net?
Submitted by Nidhi, on November 26, 2020

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.

Program/Source Code:

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 »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.