Passed Variable & adding "1"

Results 1 to 4 of 4

Thread: Passed Variable & adding "1"

  1. #1
    Chuck Ezell Guest

    Default Passed Variable & adding "1"

    I want to add 1 to the value I&#039;m passing (1,2,3,4, etc..) but this won&#039;t work.<BR><BR>&#060;%<BR>For x = 1 to 1000 Step 1<BR> next_var = "new_index.asp?dyn=" & Request.QueryString("dyn") & "+ Cstr(x)" <BR>Next<BR>%&#062;<BR><BR><BR>Any ideas?<BR><BR>

  2. #2
    J. Paul Schmidt Guest

    Default Don't Quote the Variable

    You wrote that the following code doesn&#039;t work properly:<BR>next_var = "new_index.asp?dyn=" & Request.QueryString("dyn") & "+ Cstr(x)"<BR><BR>Perhaps change it more like the following:<BR>next_var = "new_index.asp?dyn=" & Request.QueryString("dyn") & Cstr(x)<BR><BR>Best regards,<BR>-Paul<BR><BR>J. Paul Schmidt, MBA<BR>Databases on the Web<BR><BR>

  3. #3
    Chuck Ezell Guest

    Default RE: Don't Quote the Variable ERRORS

    I tried it a couple of ways & I get an error.<BR><BR>/index/new_index.asp, line 124, column 24<BR>next_var = new_index.asp?dyn= & Request.QueryString("dyn") & Cstr(x)<BR>-----------------------^<BR><BR><BR>

  4. #4
    Join Date
    Dec 1969

    Default He meant don't quote the NUMBER...

    Of *course* you have to quote the parts that are really strings!<BR><BR>&#060;%<BR>next_var = "new_index.asp?dyn=" & ( CDbl(Request.QueryString("dyn")) + x )<BR>%&#062;<BR><BR>And you *ALSO* shouldn&#039;t convert the "x" from number to string if you want to USE it as a number! CStr converst to a string. CDbl converts to a number. If you want to ADD things numerically, add numbers, not strings. Simple as that.<BR><BR>You need to go back to your ASP book and read up more on how different data types -- strings vs. numbers vs. dates vs. whatever -- are used in programs.<BR><BR><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