Reputation: 837
I have this elements:
Type Posizione
Name As String
Position As Byte
End Type
Public Location() as Posizioni
I'd like to loop between the minimum posizione().valore and the max one.
I tried with:
For i = LBound(Location().position) To UBound(Location().position)
But I receive "Invalid Qualifier" in this position.
Any suggestions?
Upvotes: 0
Views: 1344
Reputation: 5721
You will have to find the min and max values before iterating between them. Something like this will do that:
Dim PosMin As Byte
Dim PosMax As Byte
PosMin = 255
PosMax = 0
For i = LBound(Location) To UBound(Location)
If Location(i).Position > PosMax Then
PosMax = Location(i).Position
End If
If Location(i).Position < PosMin Then
PosMin = Location(i).Position
End If
Next
For i = PosMin To PosMax
Debug.Print i
Next i
Upvotes: 1
Reputation: 29286
Your array is the variable Location
, so you have to use this as parameter to lbound
and ubound
For i = LBound(Location) To UBound(Location)
Location(i).position = i
Location(i).Name = "Hello " & i
Next i
Upvotes: 2