I have this simple code, the idea is to find the the minimum value out of an array containing numbers, it works, most of the time:
For yy As Integer = 0 To 23
If (IsNumeric(data(2, yy))) Then
If (yy > 0) Then
If (data(2, yy) < min(days)) Then
min(days) = data(2, yy)
End If
Else
min(days) = data(2, yy)
End If
End If
Next
Now, the data array may or may not contain values, the code has no problem working when the first position in the array has a value, even if other positions in the array are empty. The problem is when the first position of the array is empty, even if the rest of the array is full of values, it wont read any of them, any ideas?
In your scenario, in the first loop you set min(days)
to zero.
Then in the subsequent loop (yy=1 etc...) you check the value contained in data(2, yy)
with the same min(days)
that you have set to zero in the first loop.
Thus you never get a true condition for the if(data(2,yy) < min(days)
unless data(2,yy) is less than zero
It seems that you have something wrong because you use always the same value min(days)