- 5
- 0
- 约9.68千字
- 约 16页
- 2017-10-07 发布于河南
- 举报
数组精华(Array essence)
数组精华(Array essence)
Declare array
The array declaration is the same as other variables, which can be declared using Dim, Static, Private, or Public statements. Scalar variables (non arrays) differ from array variables in that they usually have to specify the size of the array. If the size of the array is specified, it is a fixed size array. If the size of an array can be changed when the program is running, it is a dynamic array.
Whether the array is indexed from 0 or 1 is based on the setting of the Option Base statement. If Option Base is not specified as 1, then the index of the array starts from zero.
Declare a fixed size array
The following line of code declares a fixed size array, which is a Integer array of 11 rows multiplied by 11 columns:
Dim MyArray (10, 10) As Integer
The first parameter represents the row; the second parameter represents the column.
Like the declarations of other variables, the data type of the element in the array is declared to be Variant, unless a data type is specified. The numeric Variant element of each array in the array occupies 16 bytes. Each string type Variant element occupies 22 bytes. To make the written code as concise as possible, you must explicitly declare the array as a data type, not a Variant. The following lines of code compare the sizes of several different arrays:
An integer array uses 22 bytes (11 elements * 2 bytes)
ReDim MyIntegerArray (10) As Integer
double precision array uses 88 bytes (11 elements * 8 bytes).
ReDim MyDoubleArray (10) As Double
An array of variants uses at least 176 bytes (11 elements * 16 bytes).
ReDim MyVariantArray (10)
The integer array uses 100 * 100 * 2 bytes (20000 bytes).
ReDim MyIntegerArray (99, 99) As Integer
double precision array uses 100 * 100 * 8 bytes (80000 bytes).
ReDim MyDoubleArray (99, 99) As Double
An array of variants uses at least 160000 bytes (100 * 100 * 16 bytes).
ReDim MyVariantArray (99, 99)
The maximum value of an array variable is based on how much memory is avai
您可能关注的文档
- 战略营销21世纪企业的指导思想(Strategic marketing the guiding ideology of enterprises in twenty-first Century).doc
- 战略管理的定位偏差(Positioning deviation of strategic management).doc
- 战略转型(Strategic transformation).doc
- 战略那些事儿,总是上边热下边冷(Strategy is always hot and cold at the bottom).doc
- 战略风险管理体系(Strategic risk management system).doc
- 战神的挑战捉宠攻略(God of war challenge catch pet strategy).doc
- 戴尔 vostro 1088 笔记本电脑配置(戴尔 your 笔记本电脑配置 1088).doc
- 房产测量规范(House property survey standard).doc
- 房价会跌(House prices will fall).doc
- 房地产企业会计处理(配套设施开发成本的核算)(Accounting treatment of real estate enterprises (accounting for development costs of ancillary facilities)).doc
原创力文档

文档评论(0)