6
I would like to know how to have the size of my vector in VBA.
I searched some things but could not locate anything. How can I recover this value?
6
I would like to know how to have the size of my vector in VBA.
I searched some things but could not locate anything. How can I recover this value?
4
The array size can be obtained using the function Ubound. Note, however, that this function does not return the vector size, but the last accessible index.
See the example below:
Sub teste()
Dim s(1) As String
s(0) = "L"
s(1) = "B"
MsgBox UBound(s)
End Sub
Msgbox Ubound(s) will show 1 (the last accessible index) and not 2 (the vector size).
Therefore, to know the size, just add + 1 (Msgbox Ubound(s) + 1)
Thanks Cantoni worked here thanks!
Browser other questions tagged vba
You are not signed in. Login or sign up in order to post.
vetor.Length
doesn’t work?– Felipe Avelar
@Felipeavelar, in the case of VBA, the vector is not an object. There are no methods or attributes that you can access to, for example, get the size.
– cantoni