Function double Learn programming Visual Basic (VB.net)

Lesson:

Functions


Exercise:

Function double 12


Objetive:

Create a function named "Double" to calculate and return an integer number doubled. For example. Double(7) should return 14.


Code:

Imports System
Public Class exercise104
    Public Shared Function Double(ByVal number As Integer) As Integer
        Return number * 2
    End Function

    Public Shared Sub Main()
        Console.Write("Enter a number: ")
        Dim number As Integer = Convert.ToInt32(Console.ReadLine())
        Console.WriteLine("Double of {0} is {1}", number, Double(number))
    End Sub
End Class