Quick easy problem

wildfire1982

Regular
Joined
Oct 23, 2003
Messages
50
Location
Southampton
Hello folks,

Its morning here and im havin troubles finding a very small bug in a very small loop. Sorry to have to ask you this but i cant seem to find it for some strange reason so could someone please let me know where i am being stupid. Thanks very much.

The following loop works but only checks the first and last of the values. I.e. if numIngreds =5 then only the first and fifth elements of the array will be checked, missing the ones in the middle. Im sure its just me being stupid but i really cant see it.

Visual Basic:
 For counters = 1 To Module1.numIngreds + 1
            Dim testVar As String = Module1.ingredientsList(1, counters)
            If Module1.ingredientsList.GetValue(1, counters) = "" Or Module1.ingredientsList.GetValue(1, counters) = Nothing Then
                Module1.ingredientsList(1, counters) = Module1.ingredientsList.GetValue(1, counters + 1)
                Module1.ingredientsList(2, counters) = Module1.ingredientsList.GetValue(2, counters + 1)
                counters2 = counters2 + 1
                MessageBox.Show("its realised that there is a gap and so has tried to move it all")
            End If
            counters = counters + 1
        Next

Cheers guys and gals.
 
Back
Top