Hi Team
I know array start with zero by default, by declaring option base1 it will start from 1 ,
is it possible to start an array from 2?... plz help new in array
Regards,
Mallesh
Printable View
Hi Team
I know array start with zero by default, by declaring option base1 it will start from 1 ,
is it possible to start an array from 2?... plz help new in array
Regards,
Mallesh
Code:Dim myArray(2 to 10)
Dim SomeVariable As Variant
Dim OtherVar(1 to 10, 1 to 10)
ReDim SomeVariable(2 to 20)
Redim OtherVar(2 to 11, 2 to 11)
You can (as Sam said) start arrays at any start/end
The Option Base is for when you do NOT explicitly specify
So if you can pick your bounds correctly, you can make life easier. You should use LBound and UBound
Example: working with rows 16 to 32
Code:Dim A (16 to 32) as Long
For r = LBound(A) to UBound(A)
Cells(r,1).Value = 2*Cells(r,2)
Next r
or even use enumerations
Code:Dim D(vbSunday to vbSaturday)
If you define your own enumerations, it does help readability
Code:Enum colNames
FName =12
LName = 13
Addr = 14
End Enum
Dim N(FName to Addr)