OutOfBoundsException

From REALbasicWiki

Jump to: navigation, search
Overall article skill Skill ranges from beginner (green) to expert (red)
OutOfBoundsException class
Available on Mac OS X Linux Windows
General
Superclass RuntimeException
Interfaces none
Constants

none

Methods

none

Properties

none

Events

none

NOTE: You can get descriptions of the items above from the REALbasic documentation.


An OutOfBoundsException is raised when you attempt to access something by index, and the index passed is not in the correct range.

[edit] Discussion

The usual source of an OutOfBoundsException is code that reads from or assigns to an array. Some other framework methods also raise OutOfBoundsExceptions.

[edit] Sample Code

A trivial example.

dim theList(-1) as String
return theList(0) //an OutOfBoundsException is raised

In the code below, an OutOfBoundsException is raised when i = 10; dimming an array sets the UBound of an array, which is one less than the number of elements.

dim theList(9) as Integer
for i as Integer = 1 to 10
theList(i) = i
next
Personal tools
related