What could UBound = -1 mean?

Lai Kan Leon 596 Reputation points
2021-08-21T13:30:31.633+00:00

Hello,

I have a 1-dimensional array (say 0 To 10) which I "emptied" using:

vIntermediate1_1D = Array()

I had the curiosity to use MsgBox to check what are the LBound and UBound of my array after emptying:

I got:
LBound = 0
UBound = -1

I am puzzled: What could an UBound of -1 mean?

How can the array be like this: vIntermediate1_1D (0 To -1)?

Thanks for bringing some light.

Leon

Developer technologies | Visual Basic for Applications
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 90,686 Reputation points
    2021-08-21T13:50:52.343+00:00

    You can see the doc UBound Function (Visual Basic) :

    Return Value

    Integer. The highest value the subscript for the specified dimension can contain. If Array has only one element, UBound returns 0. If Array has no elements, for example if it is a zero-length string, UBound returns -1.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.