Solved

Arithmetic operation resulted in an overflow.

Posted on 2009-05-06
3
408 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

828 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