For Next Statement - Until end or array?? {Solved}
Hi, im guessing this answer is very simple so sorry for the easy question, I just for some reason couldn't find the answer.
All I want to do is go through an array until you hit the last index, if that makes any sense. I have an array which could have any amount of indexes..
So I want to do something like this:
VB Code:
Private Sub CheckStatus()
Dim Checks() As Integer
Dim CellText As String
CellText = DetailsGrid.CellText((llRow - 2), 5)
Checks() = Split(CellText, "; ")
For Checks() = 1 To Last
' Do whatever..
Next
End Sub
So what could I do to find out the last index of an array? Im sure you could use LBound and UBound to do it but I have never used them before. Thanx all for the help!
Re: For Next Statement - Until end or array??
this should do it
dim ArrayLength as integer
arraylength = ubound(checks())
for i = 1 to arraylength
or
for i = 1 to arraylength - 1
I dont really remember which :/
Re: For Next Statement - Until end or array??
The best way would be:
For I = LBound(strArray()) To UBound(strArray())
Next I
because that will work wether the array is zero based, or anything else.
Re: For Next Statement - Until end or array??