Saturday, January 4, 2014

First 4 Console Applications in VB.NET

Module Prog1

    Sub Main()

        Dim a, b As Integer
        Dim ans As Decimal

        Console.WriteLine("Enter First Value")
        a = Console.ReadLine()

        Console.WriteLine("Enter Sec Value")
        b = Console.ReadLine()

        ans = a + b
        Console.WriteLine("Your Addition Ans = " & ans)

        ans = a - b
        Console.WriteLine("Your Subtract Ans = " & ans)


        ans = a * b
        Console.WriteLine("Your Multiply Ans = " & ans)

        ans = a / b
        Console.WriteLine("Your Division Ans = " & ans)

        Console.ReadLine()

    End Sub

End Module


Module Prog2

    Sub main()

        Dim first, sec, last As String

        Console.WriteLine("Enter First Name")
        first = Console.ReadLine()

        Console.WriteLine("Enter Middle Name")
        sec = Console.ReadLine()

        Console.WriteLine("Enter Last Name")
        last = Console.ReadLine()

        Console.WriteLine("Your Full Name    : " & first & "  " & sec & "  " & last)

        Console.ReadLine()
    End Sub

End Module


Module Prog3
    Sub main()

        Dim a As Integer

        Console.WriteLine("Enter Number")
        a = Console.ReadLine()

        If a Mod 7 = 0 Then
            Console.WriteLine("Yes, Its Divisible by 7")
        Else
            Console.WriteLine("No, Its not Divisible by 7")
        End If

        Console.ReadLine()

    End Sub
End Module


Module Prog4
    Sub main()
        Dim a As Integer

        Console.WriteLine("Enter Value")
        a = Console.ReadLine()

        If a < 0 Then
            a = -a
            Console.WriteLine("Now its : " & a)
        ElseIf a > 0 Then
            a = -a
            Console.WriteLine("Now its :" & a)
        Else
            Console.WriteLine("Invalid Choice")
        End If

        Console.ReadLine()

    End Sub
End Module

No comments:

Post a Comment