UBOUND: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "The {{KW|UBOUND}} function returns the largest valid index (upper bound) of an array dimension. {{PageSyntax}} :''result%'' = {{KW|UBOUND}}(arrayName[, dimension%]) {{PageDescription}} * {{Parameter|arrayName}} specifies the name of the array. * {{Parameter|dimension%}} specifies the dimension number, starting with <code>1</code> for the first dimension. ** If omitted, {{Parameter|dimension%}} is assumed to be <code>1</code>. ** If {{Parameter|dimension%}} is less t...")
 
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
The {{KW|UBOUND}} function returns the largest valid index (upper bound) of an array dimension.
The [[UBOUND]] function returns the largest valid index (upper bound) of an array dimension.




{{PageSyntax}}
{{PageSyntax}}
:''result%'' = {{KW|UBOUND}}(arrayName[, dimension%])
:''result%'' = [[UBOUND]](arrayName[, dimension%])




Line 9: Line 9:
* {{Parameter|arrayName}} specifies the name of the array.
* {{Parameter|arrayName}} specifies the name of the array.


* {{Parameter|dimension%}} specifies the dimension number, starting with <code>1</code> for the first dimension.
* {{Parameter|dimension%}} specifies the dimension number, starting with '''1''' for the first dimension.
** If omitted, {{Parameter|dimension%}} is assumed to be <code>1</code>.
** If omitted, {{Parameter|dimension%}} is assumed to be '''1'''.
** If {{Parameter|dimension%}} is less than <code>1</code> or is greater than the number of dimensions, a [[ERROR Codes|subscript out of range]] error occurs.
** If {{Parameter|dimension%}} is less than '''1''' or is greater than the number of dimensions, a [[ERROR Codes|subscript out of range]] error occurs.


* {{KW|UBOUND}}, along with {{KW|LBOUND}}, is used to determine the range of valid indexes of an array.
* [[UBOUND]], along with [[LBOUND]], is used to determine the range of valid indexes of an array.




Line 29: Line 29:


{{PageSeeAlso}}
{{PageSeeAlso}}
* {{KW|Arrays}}, {{KW|LBOUND}}
* [[Arrays]], [[LBOUND]]
* {{KW|DIM}}, {{KW|COMMON}}, {{KW|STATIC}}, {{KW|SHARED}}
* [[DIM]], [[COMMON]], [[STATIC]], [[SHARED]]




{{PageNavigation}}
{{PageNavigation}}

Latest revision as of 00:58, 25 January 2023

The UBOUND function returns the largest valid index (upper bound) of an array dimension.


Syntax

result% = UBOUND(arrayName[, dimension%])


Description

  • arrayName specifies the name of the array.
  • dimension% specifies the dimension number, starting with 1 for the first dimension.
    • If omitted, dimension% is assumed to be 1.
    • If dimension% is less than 1 or is greater than the number of dimensions, a subscript out of range error occurs.
  • UBOUND, along with LBOUND, is used to determine the range of valid indexes of an array.


Examples

DIM myArray(5) AS INTEGER
DIM myOtherArray(1 to 2, 3 to 4) AS INTEGER

PRINT UBOUND(myArray)
PRINT UBOUND(myOtherArray, 2)
 5
 4


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link