Results 1 to 2 of 2

Thread: Do I need to convert request.QueryString to Long?

  1. #1

    Thread Starter
    Addicted Member diban's Avatar
    Join Date
    Aug 2002
    Location
    IN
    Posts
    152

    Do I need to convert request.QueryString to Long?

    Hi

    I am using a variable in my calc.aspx file to do some calculations:

    Dim mLogKey as Long
    Dim mBase as Long

    mLogKey = Request.QueryString("LogKey")
    mBase=Request.QueryString("Base")

    I get my value from another form in another file that calls this file as something like this:

    action="calc.aspx?LogKey=21&Base=3.14"


    I get the following compile error:

    Code:
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    
    Exception Details: System.FormatException: Input string was not in a correct format.
    
    theData=request.QueryString("LogKey")
    Do I need to Convert the String into Int/Long?

    Thanks

    Diban

  2. #2
    Fanatic Member aconybeare's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    772

    Re: Do I need to convert request.QueryString to Long?

    Diban,

    I'm no expert but I would say yes you do

    something like -
    You may need to check they're not null before calling "CLng" else you'll get an error, also ensure they're actually numbers

    VB Code:
    1. mLogKey = [b]cLng([/b]Request.QueryString("LogKey")[b])[/b]
    2. mBase= [b]cLng([/b]Request.QueryString("Base")[b])[/b]

    Also if you've not done it already you should turn option Strict on, which will prevent you from making these type of errors when you build your page

    On the main toolbar click Project - [ProjectName] Properties - Select build from the list on the left - then turn on "Option Strict"

    Hope this helps

    Cheers Al
    Last edited by aconybeare; Sep 16th, 2005 at 11:38 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width