?
Solved

Using CLng gives overflow?

Posted on 2005-03-23
7
Medium Priority
?
8,332 Views
Last Modified: 2008-01-09
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
0
Comment
Question by:amoran
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 5

Expert Comment

by:dr_binks
ID: 13610118
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
 

Expert Comment

by:svgharmode
ID: 13610124
Dear Friend,

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

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


Cheers

Sanjeev
0
 

Author Comment

by:amoran
ID: 13610283
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 9

Accepted Solution

by:
danataylor earned 100 total points
ID: 13611102
Trim strValue to remove any leading/trailing spaces before you do the conversion.
0
 
LVL 5

Expert Comment

by:Vinod_VijayanVin
ID: 13611432


   Use     CLng(trim(myval))
0
 
LVL 5

Expert Comment

by:Vinod_VijayanVin
ID: 13611451

if that also crashes Use  CDbl(trim(myval))
0
 

Expert Comment

by:svgharmode
ID: 13618801
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question