Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference > Siebel VB Language Reference >
UBound Function
This standard VB function returns the upper bound of the subscript range for the specified array.
Syntax
UBound(arrayName[, dimension ])
Argument Description arrayName The variable name of the array to be tested dimension The array dimension whose upper bound is to be returnedReturns
The upper bound of the subscript range for the specified dimension of the specified array.
Usage
The dimensions of an array are numbered starting with 1. If dimension is not specified, 1 is used as a default.
LBound can be used with UBound to determine the length of an array.
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) = 88
x = x + 1
Loop
x = LBound(arrayvar,1)
count = UBound(arrayvar,1)
For y = x to count
total = total + arrayvar(y)
Next y
End SubSee Also
Dim Statement
Global Statement
LBound Function
Option Base Statement
ReDim Statement
Static Statement
Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference Published: 18 June 2003 |