Stumped with If..Then..Else statement.

Results 1 to 2 of 2

Thread: Stumped with If..Then..Else statement.

  1. #1
    Shawn Kubik Guest

    Default Stumped with If..Then..Else statement.

    I&#039;m so stumped on this problem, I&#039;ve almost ripped all my hair out! It&#039;s so simple, but for some reason it doesn&#039;t want to work.<BR><BR>My problem is, in a block of ASP code on a search results page, I have an If..Then..Else statement that determines whether to display a link to the next page of results or not. I have two variables: currPage, which holds the current page number as retrieved from a Request.QueryString, and numPages, which is returned from a function called detNumPages, which calculates the number of pages needed to display all the results.<BR><BR>Here&#039;s some sample code:<BR><BR>Dim currPage<BR>Dim numPages<BR><BR>currPage = Request.QueryString("page")<BR>numPages = detNumPages(myRecordset.RecordCount)<BR><BR>&#039; currPage now holds, say, 1<BR>&#039; numPages now holds, say, 2. Yes, my recordset is defined using the proper cursor settings and such, and my function merely calculates the number of pages needed and returns the number.<BR><BR>....<BR><BR>If (currPage &#060; numPages) Then<BR> Response.Write("&#060;A HREF=&#039;SearchResults.asp?page=" & currPage+1 & "&#039;&#062;Next Page&#060;/A&#062;")<BR>Else<BR> Response.Write("Next Page")<BR>End If<BR><BR>SO what should happen is when this block is executed, as long as currPage is less than numPages, it will display the link... however, no matter what page I&#039;m on it will ALWAYS go to the &#039;Else&#039; part of the statement and output the non-link instead. I&#039;ve even stuck a Response.Write right before the If statement to spit out the values of currPage and numPages and they are exactly what they should be, but it still doesn&#039;t work.<BR><BR>Any ideas? Is taking the currPage value from the QueryString maybe the problem? Any ideas of how I can remedy this problem? I&#039;ve been fiddling with this problem for almost a week and I can&#039;t figure out any way around it... thus, the development of the rest of my project has come to a halt. Any help would be HUGELY appreciated.<BR><BR>Thank you,<BR><BR>- Shawn Kubik.

  2. #2
    Join Date
    Dec 1969

    Default RE: Stumped with If..Then..Else statement.

    1. why have you written a function to detect the number of pages when the recordset object has a .pageCount property?<BR>2. have you tried casting the variables into integers before doing the if() comparison? you&#039;re probably trying to compare an object to an integer at the moment, whch will always go through to else...<BR><BR>j

Posting Permissions

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