Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why would if /then/else cause a "loop" error?

Status
Not open for further replies.

crashc123

Technical User
Oct 3, 2001
80
US
What is the best way to present this argument?
I want A to equal anthing other than nothing and C<=B<D

(B is a date, C=Today's date and D = one week from today)

If A equal to something & b is between c&D, do #1
If A equal to something & B is not between c&d, do #2
If A is equal to nothing & B is between c&D, Do #3
If A is equal to nothing & B is not between c&d, Do #4

I have this
IF A=&quot;&quot; and b=C or C<b<d then
Response.Write&quot;<tr bgcolor=red>&quot;
Else
If A=&quot;&quot; then
Response.Write &quot;<tr bgcolor= green>&quot;
Else
If A<>&quot;&quot; and B=C or C<b<d then Response.Write &quot;<tr bgcolor=yellow>&quot;
Else
if rstDBEdit.Fields(&quot;Engineer&quot;)<>&quot;&quot; then
Response.Write&quot;<tr>&quot;
End If
End If
End If


WhenI do this I get a Error Type:
Microsoft VBScript compilation (0x800A040E)
'loop' without 'do'
/Projectlist.asp, line 370
Loop



my above code is contained within the loop. The Do is above this code and the loop which it is recognizing is after the above

Also when I comment the above code out everything works fine.
Trying to color certain rows in a table.
 
Oops hit submit instead of edit......

last if statement should read

if a<>&quot;&quot; then
Respones.Write&quot;<tr>&quot;
 
If you put in proper indentation you would see that you were one END IF short and thus encountered a LOOP where there was no DO in the same block. I think yopu loghic also requires parens because A=&quot;&quot; and b=C or C<b<d is equivalent to (A=&quot;&quot; and b=C) or C<b<d and I think you want
A=&quot;&quot; and (b=C or C<b<d)
Code:
IF A=&quot;&quot; and b=C or C<b<d then
    Response.Write&quot;<tr bgcolor=red>&quot;
Else
    If A=&quot;&quot; then
        Response.Write &quot;<tr bgcolor= green>&quot;
    Else
        If A<>&quot;&quot; and B=C or C<b<d then Response.Write &quot;<tr bgcolor=yellow>&quot;
        Else
            if rstDBEdit.Fields(&quot;Engineer&quot;)<>&quot;&quot; then
                                Response.Write&quot;<tr>&quot;
            End If    
        End If
    End If
END IF
'*** EASIER
[code]
IF A=&quot;&quot; and b=C or C<b<d then
    Response.Write&quot;<tr bgcolor=red>&quot;
ElseIf A=&quot;&quot; then
    Response.Write &quot;<tr bgcolor= green>&quot;
ElseIf A<>&quot;&quot; and B=C or C<b<d then Response.Write &quot;<tr bgcolor=yellow>&quot;
Elseif rstDBEdit.Fields(&quot;Engineer&quot;)<>&quot;&quot; then
    Response.Write&quot;<tr>&quot;
END IF
Compare Code (Text)
Generate Sort in VB or VBScript
 
Thanks a bunch. not at my computer but will give it a try.

Sonya
;-)
 
Still ignoring the &quot;AND&quot; part of the statements, everything is either red or yellow. How can I make it qualify the part after &quot;and&quot; so the other colors are included?
 
if A = &quot;&quot; then
if b >= c and b <= d then
Response.Write&quot;<tr bgcolor=red>&quot;
else
Response.Write &quot;<tr bgcolor= green>&quot;
end if
else
if b >= c and b <= d then
Response.Write &quot;<tr bgcolor=yellow>&quot;
else
if rstDBEdit.Fields(&quot;Engineer&quot;)<>&quot;&quot; then
Response.Write&quot;<tr>&quot;
end if
end if
end if


Try this, it should work based on your details.
Have Fun...

Sharky99 >:):O>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top