Option Base 1

B

Bill

I have a class module that uses the option: "Option Base 1"
In that module, I have a variable:
Dim CDVals() as string

and (example only)

CDVals = Split("a,b,c,d,e,f" ",")

That should yield an allocated array with LBound of 1
and a UBound of 6. However, even with the Base 1
option specified at the beginning of the module, the
bounds are 0 to 5.

Is there something special about arrays that are allocated
at runtime? I.e., their dimensions?

Bill
 
D

Dirk Goldgar

Bill said:
I have a class module that uses the option: "Option Base 1"
In that module, I have a variable:
Dim CDVals() as string

and (example only)

CDVals = Split("a,b,c,d,e,f" ",")

That should yield an allocated array with LBound of 1
and a UBound of 6. However, even with the Base 1
option specified at the beginning of the module, the
bounds are 0 to 5.

Is there something special about arrays that are allocated
at runtime? I.e., their dimensions?

I think the Option Base statement only affects arrays that are allocated
within the module that contains the statement. But the array returned
by the Split statement is not allocated in that module; it's allocated
externally to the module. Note that the help entry for the Split
Function says categorically, "Returns a *zero-based* [emphasis mine],
one-dimensional array containing a specified number of substrings."
 
B

Bill

Ah yes, "external" being the operative word. Makes sense, given
the implementation of VBA.
Thanks,
Bill


Dirk Goldgar said:
Bill said:
I have a class module that uses the option: "Option Base 1"
In that module, I have a variable:
Dim CDVals() as string

and (example only)

CDVals = Split("a,b,c,d,e,f" ",")

That should yield an allocated array with LBound of 1
and a UBound of 6. However, even with the Base 1
option specified at the beginning of the module, the
bounds are 0 to 5.

Is there something special about arrays that are allocated
at runtime? I.e., their dimensions?

I think the Option Base statement only affects arrays that are allocated
within the module that contains the statement. But the array returned
by the Split statement is not allocated in that module; it's allocated
externally to the module. Note that the help entry for the Split
Function says categorically, "Returns a *zero-based* [emphasis mine],
one-dimensional array containing a specified number of substrings."

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top