Siebel VB Language Reference > Siebel VB Language Reference >

Option Base Statement


This standard VB statement specifies the default lower bound to use for array subscripts.

Syntax

Option Base lowerBound

Placeholder
Description
lowerBound
Either 0 or 1 or an expression that evaluates to one of these values

Returns

Not applicable

Usage

If no Option Base statement is specified, the default lower bound for array subscripts is 0.

The Option Base statement is not allowed inside a procedure and must precede any use of arrays in the module. Only one Option Base statement is allowed per module. It must be placed in the (general) (declarations) section in the Siebel VB Editor, as shown in Figure 1.

Figure 1.  Placing Declarations in the (general) (declarations) Section

Click for full size image

Example

This example resizes an array if the user enters more data than can fit in the array. It uses LBound and UBound to determine the existing size of the array and ReDim to resize it. Option Base sets the default lower bound of the array to 1.

Option Base 1
Sub Button_Click
   Dim arrayvar() as Integer
   Dim count as Integer
   Dim answer as String
   Dim x, y as Integer
   Dim total
   total = 0
   x = 1
   count = 2
   ReDim arrayvar(count)
start:
   Do until x = count + 1
      arrayvar(x) = 87
      x = x + 1
   Loop
   x = LBound(arrayvar,1)
   count = UBound(arrayvar,1)
   For y = x to count
         total = total + arrayvar(y)
      Next y
End Sub

See Also

Dim Statement
Global Statement
LBound Function
ReDim Statement
Static Statement


 Siebel VB Language Reference
 Published: 18 June 2003