If, symbols Learn programming Visual Basic (VB.net)

Lesson:

Basic Data Types


Exercise:

If, symbols


Objetive:

Create a program to ask the user for a symbol and answer if is an uppercase vowel, a lowercase vowel, a digit or any other symbol, using "if".


Code:

Imports System
Public Class exercise64
    Public Shared Sub Main()
        Dim symbol As Char
        Console.Write("insert anything: ")
        symbol = Convert.ToChar(Console.ReadLine())

        If symbol >= "0"c AndAlso symbol <= "9"c Then
            Console.WriteLine("it's a number")
        ElseIf (symbol = "a"c) OrElse (symbol = "e"c) OrElse (symbol = "i"c) OrElse (symbol = "o"c) OrElse (symbol = "u"c) Then
            Console.WriteLine("it's a lowercase vowel")
        ElseIf (symbol = "A"c) OrElse (symbol = "E"c) OrElse (symbol = "I"c) OrElse (symbol = "O"c) OrElse (symbol = "U"c) Then
            Console.WriteLine("it's a upercase vowel")
        Else
            Console.WriteLine("it's a symbol")
        End If
    End Sub
End Class

Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.