[RESOLVED] Help with loop!!!
Hi
I have written a loop-code but I get this message "Loop without Do". Now I have checked the code and i cant find whats wrong with it. Theres only one loop in the code so I cant see why the program doesnt recognise the first "Do" statement.
This is the code (somewhat shortened though)
VB Code:
For i = 1 To iEnd
bordervalue = 0.001
bX1temp = ws.Cells(i, "a").Value
bX2temp = ws.Cells(i, "d").Value
bY1temp = ws.Cells(i, "b").Value
bY2temp = ws.Cells(i, "e").Value
Do
bEnough = True
bXMtemp = (bX1temp + bX2temp) / 2
bYMtemp = (bY1temp + bY2temp) / 2
If bXMtemp < dXMin Then
If 0 > Me.txtP1X.Value > bXMtemp Then
bP1xxM = dP1 * (bXMtemp - Me.txtP1X.Value)
End If
If 0 > Me.txtP2X.Value > bXMtemp Then
bP2xxM = dP2 * (bXMtemp - Me.txtP2X.Value)
End If
If 0 > Me.txtP3X.Value > bXMtemp Then
bP3xxM = dP3 * (bXMtemp - Me.txtP3X.Value)
End If
If 0 > Me.txtP4X.Value > bXMtemp Then
bP4xxM = dP4 * (bXMtemp - Me.txtP4X.Value)
End If
If 0 > Me.txtP5X.Value > bXMtemp Then
bP5xxM = dP5 * (bXMtemp - Me.txtP5X.Value)
End If
If 0 > Me.txtP6X.Value > bXMtemp Then
bP6xxM = dP6 * (bXMtemp - Me.txtP6X.Value)
End If
End If
[B] [CUT OUT CODE]....[/B]
bPxxSum = bP1xxM + bP2xxM + bP3xxM + bP4xxM + bP5xxM + bP6xxM
dY = 1 / dH * (dRa * bXMtemp - bPxxSum) + dYStrt
dX = bXMtemp
If Not bYMtemp - dY < bordervalue Then
bEnough = False
If dY < bYMtemp Then
bX2temp = bXMtemp
bY2temp = bYMtemp
End If
If dY > bYMtemp Then
bX1temp = bXMtemp
bY1temp = bYMtemp
End If
End If
Loop While Not bEnough
ws.Cells(i, "G").Value = dX
ws.Cells(i, "H").Value = dY
Next i
Does anyone have any idea to whats wrong?
Could it be that the loopcode is to long? are there any restrictions to that?
Re: [RESOLVED] Help with loop!!!
one more question though...
I fixed the loop, but now I wonder about the If statements above... does this
VB Code:
If 0 > Me.txtP4X.Value > bXMtemp Then
mean the same thing as
VB Code:
If 0 > Me.txtP4X.Value And Me.txtP4X.Value > bXMtemp Then
???
Re: [RESOLVED] Help with loop!!!
not the same
pete
edit: add code sample
VB Code:
Dim o As Integer, i As Integer, j As Integer
o = 20
i = 6
j = 8
If o > j And j > i Then Stop
If o > j > i Then Stop
Stop