Improved Integer and Numeric Conversion in ASP
The following function is for those of you who have run across this error in ASP when trying to convert a non-numeric value to an integer:
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'CInt'
This function will take anything and convert it to an integer. If the value being passed to it is not an integer, the function will return a 0 in its place.
Function IntConverter (byVal Input)
if IsNull (Input) or Input = "" or not IsNumeric (Input) then
IntConverter = 0
else
IntConverter = CInt (Input)
end if
end function
For those of you who wish to convert anything to a decimal number (not necessarily an integer), this function should do it for you:
Function DblConverter (byVal Input)
if IsNull (Input) or Input = "" or not IsNumeric (Input) then
DblConverter = 0
else
DblConverter = CDbl (Input)
end if
end function
If this helps anyone, could you please let me know? Thanks.
