'Usage:
Log(InRange(12, Array(CreateRange(0, 11), 13, CreateRange(8, 11))))
Log(InRange(12, Array(CreateRange(0, 11), 13, CreateRange(8, 20))))
Log(InRange("c", Array(CreateRange("a", "b"), "z", CreateRange("b", "c"))))
Log(InRange("c", Array(CreateRange("a", "b"), "z", CreateRange("f", "m"))))
Sub Process_Globals
Type TRange(Low As Object, High As Object)
End Sub
Public Sub CreateRange(ALow As Object, AHigh As Object) As TRange
Dim Result As TRange
Result.Initialize
Result.Low = ALow
Result.High = AHigh
Return Result
End Sub
Public Sub InRange(Val As Object, Ranges() As Object) As Boolean
If Val Is String Then
For Each O As Object In Ranges
If O Is TRange Then
If O.As(TRange).Low.As(String).CompareTo(Val) <= 0 And O.As(TRange).High.As(String).CompareTo(Val) >= 0 Then
Return True
Else If O = Val Then
Return True
End If 'Match or not
End If 'O is Range
Next
Else
For Each O As Object In Ranges
If O Is TRange Then
If O.As(TRange).Low <= Val And O.As(TRange).High >= Val Then
Return True
Else If O = Val Then
Return True
End If 'Match or not
End If 'Range or not
Next
End If 'String or not
Return False
End Sub