[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Variable is Int64 type but get error System.OverflowException

Posted on 2006-11-21
3
Medium Priority
?
370 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

649 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