Error using cint with large numbers

Posted on 2003-03-12
Medium Priority
Last Modified: 2009-07-29
I am adding 2 values together.  One is from a database and one is not... ie.

    Total = Total + NewNumber

...which gives me a type mismatch error.  So I convert NewNumber to an integer, giving me this...

    Total = Total + cint(NewNumber)

This works fine unless the value of NewNumber is outside of the -32,768 to 32,767 range, which is very possible.  If that is the case I get this error...

    Overflow: 'cint'

I tried to use the int function instead of the cint function and get this wonderful error...

    "Variable uses an Automation type not supported in VBScript"

Any ideas out there on how I can add these 2 numbers together.

Question by:maysb
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

Accepted Solution

CRagsdell earned 400 total points
ID: 8121441
Use CLng instead of CInt:

Total = CLng(Total) + CLng(NewNumber)

CLng converts to integers ranging from -2,147,483,648 to 2,147,483,647


Author Comment

ID: 8121568



Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
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 …

770 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