Solved

Arithmetic operation resulted in an overflow.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

20 Experts available now in Live!

Get 1:1 Help Now