Is there a way to find out if a subscript is out of range in an array?
You can trap specific error number in some error handler but what are you trying to do?
Microsoft MVP - Visual Basic 2006-2013 Why VB clears the clipboard on startup and how to avoid it? . Filtering Arrays . Save File To Database . Extract File From Database . Extract picture from database without using hard drive . Change Menu BackColor . How to use MS Flexgrid . Make Frame Transparent . The Easiest Way to Create an NT Service With VB6 . How to comment blocks of code in VB5 and VB6 . How to find and replace missing members of control array Visual Basic 6.0 On-Line Documentation . Connection Strings
Yep, use LBound() and UBound() to determine the valid subscript range.
XP Library • System Tray • Sorting arrays • Resize Forms • Chess Openings
Code: If YourSubscript < LBound(TheArray) Or YourSubscript > UBound(TheArray) Then MsgBox "Out of Range", vbExclamation End If
If YourSubscript < LBound(TheArray) Or YourSubscript > UBound(TheArray) Then MsgBox "Out of Range", vbExclamation End If
Assuming that's what you meant, you can also use those commands with multi-dimensioned arrays. [code] dim MyArray(5, 13) as boolean msgbox ubound(myarray, 2)
My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld Contact me on the socials www.facebook.com/lordorwell
Forum Rules