Translate

Tuesday 2 July 2013

Logical Operator And in Visual Basic.NET




 In this blog we will see Logical operator 'And ' in If Else Statement. Let us see an example progam using 'And' Operator.



 Module Example14
    Sub Main()
        Dim age As Integer
        Dim gender As String
        Console.WriteLine("Enter Your Age:")
        age = Console.ReadLine()
        Console.WriteLine("Enter your Gender M/F:")
        gender = Console.ReadLine
        If age >= 65 And gender = "M" Then
            Console.WriteLine("Senior Citizen Male")
        End If
        Console.ReadKey()
    End Sub
End Module

The above example shows use of  'And' operator.  If both age and gender  conditions are true then statements follows this condition will execute otherwise not.