adding values

Results 1 to 3 of 3

Thread: adding values

  1. #1
    charles Guest

    Default adding values

    Does anyone know the proper way to add up values taken from a form. What I&#039m trying to do is add up values from two text boxes. I tried to use Request("x") + Request("y") = z. Assuming x = 2 and y = 2, the computer shoots out 22 instead of 4. It doesn&#039t sum but appends. Thanks, Charles

  2. #2
    SPG Guest

    Default RE: adding values

    cInt(request.form("foo")) + cInt(request.form("bar")) = intFoobar<BR><BR>By default, VBScript will treat any unknown variable types (such as what the user puts in) as strings. If you know that you&#039re not getting strings, then you can tell VBScript to convert them and get on with being useful, as seen above.<BR><BR>HiH.

  3. #3
    SteveC Guest

    Default RE: adding values

    Request.QueryString returns a string, so what you&#039re essentially doing is "2" + "2", which it is correctly evaluating (much the same way "Hello " + "World" will = "Hello World"). Convert to an integer, long, or a floating number, depending on what you need.<BR><BR>CInt(Request.QueryString("X")) + CInt(Request.QueryString("Y")) will give you what you want.

Posting Permissions

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