VB.NET PROGRAM TO ADD TWO NUMBERS / INTEGERS USING FUNCTION

Module Module1

    Sub Main()
        Dim x, y, result As Integer
        Console.WriteLine("*** www.ProgrammingPosts.blogspot.com ***")
        Console.WriteLine(">>> VB.NET Console program to add two integers <<<")
        Console.Write(" Enter the first number to be added: ")
        x = Convert.ToInt32(Console.ReadLine())
        Console.Write(" Enter the second number to be added: ")
        y = Convert.ToInt32(Console.ReadLine())
        result = Sum(x, y)
        Console.Write(Environment.NewLine & " The sum of two numbers is:" & result)
        Console.ReadLine()
    End Sub
    Function Sum(ByVal a, ByVal b) As Integer
        Dim c As Integer
        c = a + b
        Return c
    End Function

End Module

Sample Output:

VB.Net Add Two Nums Using Function

Leave a Reply

Your email address will not be published.