Imports System
Public Class exercise116
Public Shared Function getInt(ByVal text As String, ByVal low As Integer, ByVal high As Integer) As Integer
Dim answer As Integer
Do
Console.Write(text)
answer = Convert.ToInt32(Console.ReadLine())
If (answer > high) Then Console.WriteLine("Not a valid answer. Must be no more than 150")
If (answer < low) Then Console.WriteLine("Not a valid answer. Must be no less than 0")
Loop While (answer < low) OrElse (answer > high)
Return answer
End Function
Private Shared Sub Main()
Dim age As Integer = getInt("Enter your age: ", 0, 150)
Console.WriteLine("The age is {0}", age)
End Sub
End Class