Imports System
Public Class MainClass
Shared Sub Main(ByVal args As String())
Dim value As Integer
' call version of Power depending on power input
value = Power(Convert.ToInt32(3), _
Convert.ToInt32(10))
Console.WriteLine( Convert.ToString(value) )
End Sub
' use iteration to calculate power
Shared Function Power(ByVal base As Integer, _
Optional ByVal exponent As Integer = 2) As Integer
Dim total As Integer = 1
Dim i As Integer
For i = 1 To exponent
total *= base
Next
Return total
End Function ' Power
End Class