Module NonExtensionExample
Sub Main()
Console.WriteLine("NonExtensionExample.vb")
Console.Write("Enter a number between 1 and 10 ==> ")
Dim i As Integer = Integer.Parse(Console.ReadLine())
Console.WriteLine("The value is {0} ", _
IIf(CheckExtensions.CheckRange(i, 1, 10), i, "out of range"))
Console.Write("Enter one of these values {CA | NY | TX | FL | NC} ==> ")
Dim state As String = Console.ReadLine().ToUpper()
Console.WriteLine("The state is {0} ", _
IIf(CheckExtensions.CheckValues(state, "CA", "NY", "TX", "FL", "NC"), state, " not in the list"))
Console.WriteLine("End of tester")
Console.ReadLine()
End Sub
End Module
Public Module CheckExtensions
'''
''' Function that performs range checking for integer data.
'''
''' The integer value to check.
''' The inclusive low value of the range to check.
''' The inclusive high value of the range to check.
''' Boolean indicating whether or not the value is within the range.
Public Function CheckRange(ByVal number As Integer, _
ByVal lowValue As Integer, _
ByVal highValue As Integer) _
As Boolean
If ((number >= lowValue) AndAlso (number <= highValue)) Then
Return True
Else
Return False
End If
End Function
'''
''' Function that checks to see if a string value is in a list of values.
'''
''' The string value to check.
''' A comma-delimited list of string values that are the
''' valid values.
''' Boolean indicating whether or not the value is in the list.
Public Function CheckValues(ByVal testValue As String, _
ByVal ParamArray values() As String) _
As Boolean
If (values.Contains(testValue)) Then
Return True
Else
Return False
End If
End Function
End Module