Using CLng gives overflow?

I'm using CLng ie CLng(myval)
but it seems to cause a crash when values are not  between -2147483648 and 2147483647.

Is there any function around I could use?

Should I write my own - if the value is greater than 9 convert it to a CDbl?
Any ideas?
Thanks
AM
amoranAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dr_binksCommented:
im assuming 'myval' is a string?
if so:

if len(myval) > 9 then
     CDbl(myval)
else
    CLng(myval)
end if

hope that helps

~Binks
0
svgharmodeCommented:
Dear Friend,

Please try this out............

Cdbl(myval) for converting the large value into number............


Cheers

Sanjeev
0
amoranAuthor Commented:
dr_binks

I do this


Function ValidateIntegerLocal(strValue)
      If ContainsInvalidCharacters(strValue,INTEGER_CHARACTER_SET) Then AspError "ValidateIntegerLocal: Invalid characters were found in input parameter ='" & Server.HtmlEncode(strValue) & "'"
      If not IsNumeric(strValue) And Len(strValue) > 0 then AspError "ValidateIntegerLocal: Non numeric characters found in input parameter ='" & Server.HtmlEncode(strValue) & "'"
      If len(strValue) > 20 Then AspError "ValidateIntegerLocal: Length of value in input parameter was too long ='" & Server.HtmlEncode(strValue) & "'"
      If Len(strValue) > 0 then
            If Len(strValue) > 10 Then
                  ValidateIntegerLocal = CDbl(strValue)
            Else
                  ValidateIntegerLocal = CLng(strValue)
            End If      
      Else
            ValidateIntegerLocal = ""
      End if
End Function


but for some reason i'm getting this error?

ValidateIntegerLocal: Non numeric characters found in input parameter ='1'

Thanks
AM
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

danataylorCommented:
Trim strValue to remove any leading/trailing spaces before you do the conversion.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vinod_VijayanVinCommented:


   Use     CLng(trim(myval))
0
Vinod_VijayanVinCommented:

if that also crashes Use  CDbl(trim(myval))
0
svgharmodeCommented:
Dear Friend,

I suggest you a simple thing To use CDBL(strValue)........... :)

    If Len(strValue) > 0 then
          If Len(strValue) > 10 Then
               ValidateIntegerLocal = CDbl(strValue)
          Else
               ValidateIntegerLocal = CLng(strValue)
          End If    
     Else
          ValidateIntegerLocal = ""
     End if

Instead of following This code.............. USE FOLLOWING CODE

    If Len(trim(strValue)) > 0 then
          ValidateIntegerLocal = CDbl(strValue)
     Else
          ValidateIntegerLocal = ""
     End if


No Need to use CLng() function.

Cheers
Sanjeev
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.