Solved

Arithmetic operation resulted in an overflow.

Posted on 2009-05-06
3
402 Views
Last Modified: 2012-05-06
What is the proper way to handle large numbers such as these? The code below causes a crash on the line:
 i = CInt(strString)

I have tried i as type Long as well.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim i As Int64 = Nothing
        Dim strString As String = Nothing
 
        Me.Label1.Text = "999,999,999,999"
        strString = (Me.Label1.Text).Replace(",", "")
        i = CInt(strString)
    End Sub

Open in new window

0
Comment
Question by:bertino12
3 Comments
 
LVL 33

Expert Comment

by:jppinto
ID: 24318607
Dim i As Long= Nothing
Dim strString As String = Nothing
 
Me.Label1.Text = "999,999,999,999"
strString = (Me.Label1.Text).Replace(",", "")
i = CInt(strString)
0
 

Author Comment

by:bertino12
ID: 24318716
No, Long causes the crash as well.
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 24318759
Try:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim i As Int64 = Nothing
        Dim strString As String = Nothing
 
        Me.Label1.Text = "999,999,999,999"
        strString = (Me.Label1.Text).Replace(",", "")
        i = Convert.ToInt64(strString)
    End Sub

Open in new window

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 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