Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CInt function

Status
Not open for further replies.

920506

Programmer
Jun 13, 2003
201
US
Hi all,
I want to make sure numberofQuoted is integer before processing. So I use the following function to make sure that the white spaces will be trimmed before it passes to CInt. It likes this CInt(Trim(Request("numberofQuoted"))).
But very intertesting thing is: one out of one hundred there is an error message stated that:
COM Error #: -2146828275 (800A000D)
* Category: Microsoft VBScript runtime
Line, Column:108, -1
Description: Type mismatch: 'CInt'
It's pointing to the line as follow:
CInt(Trim(Request("numberofQuoted")))

Just wondering how does that happen, why is just so random.

Thank you.

Betty
 
do this:

if Request("numberofQuoted")<>"" then
CInt(Trim(Request("numberofQuoted")))
end if

trim fails on null values...

-DNG

 
Hi DNG,
Thaks for your pointing that out.
Is there any typical reason, for request("variablename") not getting any value, if in my program, I already make sure the variable will have a value to be passed.

Betty
 
if you make sure that there is always a value for the request("variablename") then it shouldnt be a problem...

i would suggest doing a response.write your form variable and see what is causing the error...

-DNG
 
It might also be worthwhile to ensure that you are not somehow passing it a non-numeric value (which would also cause it to fail).

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
cint("abc") = error 800A000D and that's what the need of validation is meant for.
 
Thanks all of you for your response.
I am still bewildered by the puzzle. When I programmed,
I already tested many, many times(more than one hundred), only one time, I got this error and I just cannot figure out
the problem. Now the code is in production, I got this error again from my error log, I noticed that the user used
AOL browser.
Do you guy find any issue with browser AOL if you code mostly works fine with netscape, firefox and IE?

Thank you.

Betty
 
My thought is tat either your user managd to submit the form without filling in one of the blanks, or they managed to get to the page without going through the preceding form (like from the browser history).

Always, always, always do validation server-side before you start working with data that was posted. You never know when a user may be malicious or may have found the one strange situation where they can post half the form and not break your client-side validation.

Do a check to make sure there a value was placed in the Request.Form variable (either <> "" or IsEmpty()) and do a check to make sure it is defintely a number ( IsNumeric() ).

No matter how much time you spend testing you will always have a user somewhere that will find some way of breaking your app, either maliciously or through an inability to follow simple instructions.

-T

signature.png
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top