UBound Function
返回数组的上边界。
语法:
UBound (ArrayName [, Dimension])
返回值:
整数
参数:
ArrayName:要确定上边界 (Ubound) 或下边界 (LBound) 的数组的名称。
[Dimension]: 用于指定维的整数。函数将返回此维的上边界 (Ubound) 或下边界 (LBound)。如果未指定任何值,则返回第一维的边界。
示例:
Sub ExampleUboundLbound
Dim sVar(10 To 20) As String
Print LBound(sVar())
Print UBound(sVar())
End Sub
Sub ExampleUboundLbound2
Dim sVar(10 To 20,5 To 70) As String
Print LBound(sVar()) ' 返回 10
Print UBound(sVar()) ' 返回 20
Print LBound(sVar(),2) ' 返回 5
Print UBound(sVar(),2) ' 返回 70
End Sub