|
-
Sep 16th, 2005, 05:10 AM
#1
Thread Starter
Addicted Member
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
-
Sep 16th, 2005, 11:35 AM
#2
Fanatic Member
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:
mLogKey = [b]cLng([/b]Request.QueryString("LogKey")[b])[/b]
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|