ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

IsInterval

Determines if the Integer is of the specified interval. E.g. if the interval is 100 and the integer is 400, it would return true. 127 would return false. This function uses the Mod operator, for the above example: (300 Mod 100 = 0)

Source

''' <summary>
''' Determines if the Integer is of the specified interval.  E.g. if the interval is 100 and the integer is 400, it would return true. 
''' This function uses the Mod operator, for the above example: (300 Mod 100 = 0)
''' </summary>
''' <param name="num"></param>
''' <param name="interval"></param>
''' <returns></returns>
''' <remarks></remarks>
<Extension()> _
Public Function IsInterval(ByVal num As Integer, ByVal interval As Integer) As Boolean
    If num Mod interval = 0 Then
        Return True
    Else
        Return False
    End If
End Function

Example

Dim num As Integer = 200

If num.IsInterval(100) = True Then
   ' do something if fits the interval

End IF

Author: Blake Pell

Submitted on: 7 jul. 2010

Language: VB

Type: System.Integer

Views: 4319