|
-
Aug 1st, 2006, 05:30 AM
#1
Thread Starter
Member
[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?
-
Aug 1st, 2006, 05:59 AM
#2
Re: Help with loop!!!
the error message does not mean what it say exactly, i can't see the error in the code you posted, but it may be in the section you cut
it can be caused by and with without endwith, for without next, if without end if or do without loop, and even probaly some other code error
pete
-
Aug 1st, 2006, 06:07 AM
#3
Re: Help with loop!!!
I would suggest that you carefully check your code for missing End If/End With/End Select, etc.
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Aug 1st, 2006, 06:35 AM
#4
Thread Starter
Member
Re: Help with loop!!!
Thanks guys, You were right.
There was a "End If" missing, didn't see that first though I checked the whole code, there was so much code so I missed that and besides I didnt think that message would come up with a "End if" missing...
-
Aug 1st, 2006, 06:43 AM
#5
Thread Starter
Member
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
???
-
Aug 1st, 2006, 07:25 AM
#6
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|