Form passed numbers as string?

Results 1 to 3 of 3

Thread: Form passed numbers as string?

  1. #1
    Join Date
    Dec 1969

    Default Form passed numbers as string?

    Either my form is passing the numbers as strings -or- my vbscript is converting the pass variables to strings. It is causeing me a "Data type mismatch in criteria expression"<BR>Upon using<BR>var = request.form("passed_var") &#060;-- I need this to be a number<BR>When I tried just<BR>var = 1 the script worked perfectly. What am I doing wrong here, thanks for the help.

  2. #2
    Join Date
    Dec 1969

    Default RE: Form passed numbers as string?

    Anything passed by the request (form or querystring) collection is converted to a string. You have to convert it to a number on the next page<BR>ie.<BR>myNumber = CDbl(Request("FormFieldName"))

  3. #3
    Join Date
    Dec 1969

    Default *ALL* Request values are strings

    Always.<BR><BR>Request.Form("xxx")<BR>Request.Quer yString("YYY")<BR>Request.Cookies("xzzz")<BR>Reque st.ServerVariables("nnn")<BR><BR>Those *always* return *only* strings.<BR><BR>If you need it to be a number, "convert" it using one of VBS&#039;s built-in conversion functions:<BR><BR>CINT<BR>CDBL<BR>CLNG<BR>CSGL<BR> CSTR<BR>CBOOL<BR>CDATE<BR><BR>etc.<BR><BR>I recommend you avoid CINT and CSGL, since they both impose limits on the numbers and gain zero in performance or memory usage. CLNG for getting integers and CDBL for getting numbers with decimal points are the functions of choice.<BR><BR>intVar = CLNG( Request.Form("xxx") )<BR>or<BR>numVar = CDBL( Request.Form("xxx") )<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