Siebel VB Language Reference > VB Language Reference >
Option Base Statement
This standard VB statement specifies the default lower bound to use for array subscripts. Syntax
Option Base lowerBound
|
|
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. Option Explicit Option Base 1 Option Compare Text
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
Related Topics
Dim Statement Global Statement LBound Function ReDim Statement Static Statement
|