Solved

Variable is Int64 type but get error System.OverflowException

Posted on 2006-11-21
3
363 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
  • 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 300 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
What are the big features of MVC5? 4 57
Asp/Net Validation date Issue 9 38
Paging GridView 7 34
Different Delete Messages 7 23
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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now