Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Arithmetic operation resulted in an overflow.

Posted on 2009-05-06
3
Medium Priority
?
438 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 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
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…
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…
Loops Section Overview
Suggested Courses
Course of the Month12 days, 20 hours left to enroll

971 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