Declaring and Initialization
Option
?
Explicit
?
Sub
?arrayInVBA()
????
Dim
?a1(
5
)?
As
?
String
???? Debug.Assert?
LBound
(a1)?
=
?
0
???? Debug.Assert?
UBound
(a1)?
=
?
5
???? Debug.Assert?
TypeName
(a1)?
=
?
"
String()
"
????
Dim
?a2(
2
?
To
?
5
)?
As
?
Integer
???? Debug.Assert?
LBound
(a2)?
=
?
2
???? Debug.Assert?
UBound
(a2)?
=
?
5
???? Debug.Assert?
TypeName
(a2)?
=
?
"
Integer()
"
????
Dim
?arrayFunction:?arrayFunction?
=
?Array(
"
aa
"
,?
"
bb
"
,?
"
cc
"
,?
"
dd
"
,?
"
ee
"
,?
"
ff
"
)
???? Debug.Assert?
LBound
(arrayFunction)?
=
?
0
???? Debug.Assert?
UBound
(arrayFunction)?
=
?
5
???? Debug.Assert?
TypeName
(arrayFunction)?
=
?
"
Variant()
"
????
'
initialize?by?Array()?function
????
Dim
?i?
As
?
Integer
????
For
?i?
=
?
0
?
To
?
5
????????a1(i)?
=
?arrayFunction(i)
????
Next
?i
????
????
For
?i?
=
?
0
?
To
?
5
???????Debug.Print?a1(i)
????
Next
?i
End?Sub
posted on 2008-03-28 18:11
Jcat 閱讀(357)
評論(0) 編輯 收藏 所屬分類:
VBA