Define and Use Function: Shared Function
Imports System
Public Class MainClass
Shared Sub Main(ByVal args As String())
Dim area As Double
area = CalculateAreaFromRadius(100)
Console.WriteLine("Area: " & area)
End Sub
Shared Function CalculateAreaFromRadius(ByVal radius As Double) As Double
' square the radius...
Dim radiusSquared As Double
radiusSquared = radius * radius
' multiply it by pi...
Dim result As Double
result = radiusSquared * Math.PI
' return the result...
Return result
End Function
End Class
Related examples in the same category