Option Base 1

B

Bill

Option Base 1 does not seem to be
effective for dynamically allocated
arrays.

E.g.,
Class module:
Option Compare Database
Option Explicit
Option Base 1
..
Several subs.
..
..
Private Function VDate(strMD As String) As Integer
Dim Ar() As String
Ar = Split(strMD , "/") 'E.g., "01/01"

The Ubound(Ar) equals 1, not 2

End Function
 
M

Marshall Barton

Bill said:
Option Base 1 does not seem to be
effective for dynamically allocated
arrays.

E.g.,
Class module:
Option Compare Database
Option Explicit
Option Base 1
.
Several subs.
.
.
Private Function VDate(strMD As String) As Integer
Dim Ar() As String
Ar = Split(strMD , "/") 'E.g., "01/01"

The Ubound(Ar) equals 1, not 2

End Function


VBA Help for the Split function explicitly states that it
creates a zero based array.

AFAIK, OPTION BASE only sets the default lower bound when
you omit it in a declaration staement, e.g. Dim Ary(10).
Personally, I always use the standard 0 based arrays OR I
explicitly declare the lower bound, e.g. Dim Ary(1 To 10)
 
B

Bill

Marshall Barton said:
VBA Help for the Split function explicitly states that it
creates a zero based array.

AFAIK, OPTION BASE only sets the default lower bound when
you omit it in a declaration staement, e.g. Dim Ary(10).
Personally, I always use the standard 0 based arrays OR I
explicitly declare the lower bound, e.g. Dim Ary(1 To 10)

This was the first time I'd ever tried the use of
Option Base 1. In the past I've always used
0 origin indexing. And, as I use the Split function
quite often, I just didn't recall the explicit reference
to the base of its allocated arrays..............never
should have "changed horses".

Thanks,
Bill
 

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