Chinaunix首页 | 论坛 | 博客
  • 博客访问: 753636
  • 博文数量: 217
  • 博客积分: 2401
  • 博客等级: 大尉
  • 技术积分: 2030
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-16 06:58
个人简介

怎么介绍?

文章分类

全部博文(217)

文章存档

2023年(2)

2022年(3)

2021年(29)

2020年(12)

2019年(5)

2018年(5)

2017年(5)

2016年(3)

2015年(6)

2014年(12)

2013年(16)

2012年(9)

2011年(6)

2010年(15)

2009年(30)

2008年(59)

我的朋友

分类:

2009-01-02 05:29:00

Find The Size of  an Array

The
largest available subscript for the indicated dimension of an array can be obtained by using the Ubound function.  In our one-dimensional array example, Ubound(arr) is 5.
 
In our two-dimensional array example above, there are two upper bound figures - both are 2. 
UBound returns the following values for an array with these dimensions*:

         Dim A(1 To 100, 0 To 3, -3 To 4)

        
Statement             Return Value
        
UBound(A, 1)                         100                  
        
UBound(A, 2)                            3
        
UBound(A, 3)                            4

* Example taken from Excel VBA Help section.

The UBound function is used with the LBound function to determine the size of an array. Use the LBound function to find the lower limit of an array dimension.

        
Statement             Return Value
        
LBound(A, 1)                            1                  
        
LBound(A, 2)                            0
         LBound(A, 3)                           -3

To get the size of an array, use the following formula:

        UBound(Arr) - LBound(Arr) + 1

For example:

        Ubound(A,1) - LBound(
A,1) + 1
        =
100 - 1 + 1
        =
100

        Ubound(A,2) - LBound(A,2) + 1
        =
3 - 0 + 1
        =
4

        Ubound(A,3) - LBound(A,3) + 1
        =
4 - (-3) + 1
        =
8

阅读(1114) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~