?
Solved

Variable is Int64 type but get error System.OverflowException

Posted on 2006-11-21
3
Medium Priority
?
369 Views
Last Modified: 2008-02-01
Hi

I'm trying to do:

        Dim MyNumber As Integer
        Dim Long_Number As Int64
        MyNumber = 407,414
        Long_Number = MyNumber * 1024 * 1024
      ' Result is : 437,690,302,464
      
But got this error:

      System.OverflowException: Arithmetic operation resulted in an overflow.

It is not supposed that a long type number can store up to 9,223,372,036,854,775,807 ?

Also I try to do this:

        Long_Number = CType(MyNumber * 1024 * 1024, Int64)

But got this error: Long_Number = 0
0
Comment
Question by:Desperate34
[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
  • 2
3 Comments
 

Expert Comment

by:m_larson_33
ID: 17988055
in your
Long_Number = MyNumber * 1024 * 1024
calculation, try casting the MyNumber to Int64, otherwise I suspect the right side of this equation is by default cast to Integer.  You have Integer * 1024 * 2024, which is cast to Integer, but is too big.

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17988167
Try using Decimal.

Bob
0
 

Accepted Solution

by:
m_larson_33 earned 1200 total points
ID: 17988196
This works

        Dim MyNumber As Integer
        Dim Long_Number As Int64
        MyNumber = 407,414
        Long_Number = CType(MyNumber, Int64) * 1024 * 1024
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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

765 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