Name
Partition Function
Class
Microsoft.VisualBasic.Interaction
Syntax
Partition(number, start, stop, interval)-
number Use: Required
Data Type: Long
Number to evaluate against the intervals.
-
start Use: Required
Data Type: Long
Start of the range. Must be non-negative.
-
stop Use: Required
Data Type: Long
End of the range. Must be greater than
start.-
interval Use: Required
Data Type: Long
Size of each interval into which the range is partitioned.
Return Value
A String containing the range within which
number falls
Description
Returns a string that describes which interval contains the number
Rules at a Glance
startmust be greater than or equal to 0.stopcannot be less than or equal tostart.Partitionreturns a range formatted with enough leading spaces so that there are the same number of characters to the left and right of the colon as there are characters instop, plus one. This ensures that the interval text will be handled properly during any sort operations.If
numberis outside of the range ofstart, the range reported is:: (
start- 1)If
numberis outside the range ofend, the range reported is:(last_end_range + 1):
If
intervalis 1, the range isnumber:number, regardless of thestartandstoparguments. For example, ifintervalis 1,numberis 100, andstopis 1000,Partitionreturns100:100.If any of its arguments are
Null,Partitionreturns aNull.
Example
The code:
Dim i As Integer For i = -1 To 110 \ 5 Debug.WriteLine(CStr(i * 5) & " is in interval " & _ Partition(i * 5, 0, 100, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access