vba Ubound question

Associate
Joined
19 Jun 2006
Posts
162
Location
Swansea, Wales
Hi,

I'm trying to assign the result of Ubound(array) to a variable so i can use it as a counter but i always get a mismatched type. I've tried integers and longs and variants etc.

How can i do this?
 
No, it's not case sensitive.

OP: Only thing I can think of is one of the following:

1) You're trying to set a variable of none INT datatype to the UBound value

e.g.
Dim a AS String
a=UBound(YourArray)

2) The 'array' your setting in the UBound isn't in fact an array.
e.g.
Dim YourArray as String
Dim A As Int
A=UBound(YourArray)


As a dead easy example, the following works for me.

Dim MyArray = Array(1,2,3,4,5)

MsgBox(UBound(MyArray))

Shows a message box on the screen of 5

MsgBox(UBound(MyArray)-1)

Shows a message box on the screen of 4.
 
Back
Top Bottom