-
[RESOLVED] Weird loop...
Hi there,
I've written the following code and it works fine till 'y' hits 9. There it seems to skip the if statements and continue the loop.
Given data:
- b_x and b_y are '4'
- v_x and v_y are declared
- x and y are also looped, but in another sub
Code:
'// Define sample area
For v_x = (x - b_x) To (x + b_x)
For v_y = (y - b_y) To (x + b_y)
'// If current pixel coordinate is not negative get the colorvalue
If v_x > -1 And v_y > -1 Then
If v_x = x And v_y = y Then
Else
currHex = GetPixel(picOriginal.hdc, v_x, v_y)
currRGB = Hex2RGB(currHex)
currSample.Average_Red = currSample.Average_Red + currRGB.Red
currSample.Average_Green = currSample.Average_Green + currRGB.Green
currSample.Average_Blue = currSample.Average_Blue + currRGB.Blue
currSample.SampleCount = currSample.SampleCount + 1
pb2.Value = pb2.Value + 1
DoEvents
End If
End If
Next v_y
Next v_x
I'd appreciate some help on this :wave:
-
Re: Weird loop...
Forget it...
I forgot to change an x to a y.
That's the problem with copying and pasting...
Code:
'// Define sample area
For v_x = (x - b_x) To (x + b_x)
For v_y = (y - b_y) To (y + b_y)
'// If current pixel coordinate is not negative get the colorvalue
If v_x > -1 And v_y > -1 Then
If v_x = x And v_y = y Then
Else
currHex = GetPixel(picOriginal.hdc, v_x, v_y)
currRGB = Hex2RGB(currHex)
currSample.Average_Red = currSample.Average_Red + currRGB.Red
currSample.Average_Green = currSample.Average_Green + currRGB.Green
currSample.Average_Blue = currSample.Average_Blue + currRGB.Blue
currSample.SampleCount = currSample.SampleCount + 1
pb2.Value = pb2.Value + 1
DoEvents
End If
End If
Next v_y
Next v_x