Microsoft KB Archive/135879

= Option Base with User-Defined Type Incorrect in Help Topic =

Article ID: 135879

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 95a
 * Microsoft Excel 5.0c
 * Microsoft Excel 5.0a for Macintosh

-



This article was previously published under Q135879



SYMPTOMS
In the versions of Microsoft Excel listed above, the Help topic for the Visual Basic Option Base statement contains the following information:

The Option Base statement has no effect on arrays within user-defined types for which the lower bound is always 0.

This information is not entirely correct.



CAUSE
This statement is not true for an array within your user-defined type. For example, when you run the following code, the value 1 is returned, instead of the expected value 0 for the lower bound of the array within the user- defined type Mytype: Option Base 1

Type Mytype Machine(2) As String End Type

Sub Test_Mytype Dim Test As Mytype MsgBox LBound(Test.Machine) End Sub



WORKAROUND
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. If you want the lower bound for an array within your user-defined type to be zero, you can use any of the following methods.

Method 1
Use the "To" clause to explicitly define the upper and lower bounds of your array. This method overrides any Option Base settings in your module. The following is an example of using this method: Type Mytype Machine(0 To 2) As String End Type

Method 2
Use the Option Base statement with the value 0 by adding the following statement at the beginning of your module: Option Base 0

Method 3
Do not use the Option Base statement at all; the default base is 0.



STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Excel 97 for Windows and Microsoft Excel 98 Macintosh Edition.

