目录

# Partition 函数 [VBA]

返回一个字符串, 指示数字在计算的序列范围内出现的位置。

This constant, function or object is enabled with the statement Option VBASupport 1 placed before the executable program code in a module.

### 语法:

Partition( Number, Start, Stop, Interval)

### Return type:

String

### 参数:

「数字」: 必填。要确定分区的数字。

「开始」: 必填。一个整数, 定义数字范围的下限。

Stop: Required. An integer number defining the highest value of the range.

Interval: Required. An integer number that specifies the size of the partitions within the range of numbers (between Start and Stop).

### 示例:

            Option VBASupport 1
            Option Explicit
            Sub Test_Partition
                Dim retStr As String
                retStr = Partition(20, 0, 98, 5)
                print "20:24  数字 20 位于范围: " & retStr
                retStr = Partition(20, 0, 99, 1)
                print " 20: 20 数字 20 位于范围: " & retStr
                retStr = Partition(120, 0, 99, 5)
                print  "100:  数字 120 位于范围: " & retStr
                retStr = Partition(-5, 0, 99, 5)
                print "   : -1 数字 -5 位于范围: " & retStr
                retStr = Partition(2, 0, 5, 2)
                print " 2: 3 数字 2 位于范围: " & retStr
            End Sub

相关主题

VBA 数学函数