If Then ... If Then?

Results 1 to 3 of 3

Thread: If Then ... If Then?

  1. #1
    K. Zig Guest

    Default If Then ... If Then?

    Looking to skip sections of code if a condition is true. I want to know if I can use two "If Then" Statements together. If numrec =-1, then perform the "if then" statement below it. If it is not =-1 then skip the proceeding "if then" and jump to the next if then statement.<BR><BR>if numrec=-1 then<BR><BR>if rstrtime("Start")&#062;=1 then<BR>Response.Write "true"<BR>else Response.Write "False"<BR>End if<BR>End if<BR><BR>if rstrtime("Startrec")&#062;=1 then<BR><BR>Response.Write "Time Up"<BR>else Response.Write "Time Left"<BR>End if<BR>End if<BR><BR>Please let me know if this will work or please give ideas for other code I can use to skip sections of code if a condition is true.<BR><BR>Thanks

  2. #2
    Stephan Zutterman Guest

    Default RE: If Then ... If Then?

    Yes you can use two If ... Then statements. They are called &#039nested&#039 loops. Your code sample will not work because you have two &#039End If&#039 statements at the end of your code but you only have one &#039If .. then&#039 loop preceding. <BR><BR>Maybe it would be beter if you would use &#039Select case&#039 statements to leave out code ... like this:<BR>&#060;%<BR>Select Case numrec<BR> Case -1<BR> &#039 Code when numrec equals -1<BR> Case Else<BR> &#039 Code when numrec does not equal -1<BR>End Select<BR>&#039Next statements<BR>%&#062;

  3. #3
    Join Date
    Dec 1969

    Default RE: If Then ... If Then?

    use an else statement in your outer if/then....<BR><BR>If numrec=-1 then &#039do this code if numrec is -1<BR><BR> if rstrtime("Start")&#062;=1 then<BR> Response.Write "true"<BR> else Response.Write "False"<BR> End if<BR><BR>Else &#039do this code if numrec is not -1<BR><BR> if rstrtime("Startrec")&#062;=1 then<BR> Response.Write "Time Up"<BR> else Response.Write "Time Left"<BR> End if<BR><BR>End if<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts