Thoroughly Confused

Results 1 to 3 of 3

Thread: Thoroughly Confused

  1. #1
    Join Date
    Dec 1969

    Default Thoroughly Confused

    I am having some difficulties with a very elementary scenario.<BR>I can not get my do loop to work properly<BR>here&#039s the code<BR>count=REQUEST.FORM("hiddenField")<BR>RESPO NSE.WRITE count<BR>number = 0 <BR>Do Until number = count<BR> number = number + 1 <BR>Loop <BR><BR>I have tried this as a If Then statement and it works fine<BR>If number&#060;count Then<BR>Response.Write "Debug"<BR>End IF<BR><BR>The error Im getting is that my page times out<BR>I am thoroughly confused and cant figure this out. Is there something that Im forgetting or neglecting to consider?<BR><BR>I have also tried the following and it works fine too.<BR>number = 0 <BR>Do Until number = 5<BR> number = number + 1 <BR>Loop <BR><BR><BR>

  2. #2
    Steve Cimino Guest

    Default Strings VS Ints, the battle continues

    On first pass of your loop, VBScript "thinks" your datatype is a string. 0 &#060;&#062; "0". Your last statement will work because you&#039re setting it to a number.<BR><BR>Do this instead...<BR><BR>Do Until number = CInt(count).<BR><BR>That will clear up your problems. You&#039re getting a script timeout because you&#039re in an infinate loop.

  3. #3
    Join Date
    Dec 1969

    Default Request("...") is *always* a string...

    So when you do:<BR><BR>&#060;%<BR>count = Request("whatever")<BR>number = 0<BR>Do Until number = count<BR>...<BR>%&#062;<BR><BR>You are comparing a string (count) vs. a numeric value (number) and whether it works or not is almost pure chance.<BR><BR>So simply do<BR><BR>count = CInt( Request("whatever") )<BR><BR>to *force* the value to be a number. And if it won&#039t convert to a number, then you have a different problem (possibly junk characters in the request value).<BR><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