System.OverflowException: "The arithmetic operation caused an overflow." VB.NET

Mara

When I try to perform a search on my function based on a phone number with eg. 4444444444, this exception comes to me. How can I fix it?

This is my code:

    If IsNumeric(Trim(tbNumSearch.Text)) Then
        SearchByNumber(Val(tbNumSearch.Text)) 'this is where I get the error
    End If


  Sub SearchByNumber(ByVal telNumber As Integer)
 End Sub

But when I search with eg. 4444, I don't get this error.

I suppose I'm making a mistake in the conversion. Maybe this is a 64 bit number. Anyway, I can't find a solution. Please help.

Joel Coehoorn

I'm guessing SearchByNumber() expects an Integer. Signed Integer values only go up to about 2 billion, and can't express anything higher. In other words, it's not large enough to handle US phone numbers, which could get close to 10 billion, or 20 billion with the long-distance prefix.

You could fix this by changing to a Long, or by using Strings.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

OverflowException only in VB.net, not in C#

How to handle System.OverflowException

Unable to cast object of type 'System.Byte' to type 'System.Byte[]' - vb .net

VB.NET OverflowException on very small operation

asp.net/vb.net System.Web.UI.WebControls.RepeaterItemEventArgs question

Could not find System.Object VB.NET

System.OverflowException on converting string 0x255 to byte

printing png file with file system watcher vb.net

System.OverflowException in unchecked block of C#

vb6 to vb.net conversion 'FileName' is not a member of 'System.Windows.Forms.RichTextBox'

DLL Plugin system in VB.NET

VB.NET OverflowException was unhandled

Basic System Information in VB

Cannot perform 'Like' operation on System.Int32 and System.String. with MySQL VB.Net

How to override system default label forecolor in VB.NET

GetTempFileName throwing 'System.AccessViolationException' vb.net

VB.net chosing serial port System.IO.IOException

How to Code Favorites system in VB.NET

Independent System Time for VB.NET or MySQL

VB. NET: System.NullReferenceException occurred

Login System VB.net and Access Check if the user is an Admin

How to add a Property To a System Defined Class VB.NET

VB Net + Mysql + System.NullReferenceException

Unable to cast object of type 'WhereSelectArrayIterator`2[System.String,System.Byte]' to type 'System.Byte[]'. Vb.net

C# System.OverflowException Error in loops

Unable to cast object of type 'System.String' to type 'System.Data.DataTable' in VB.NET

Unable to cast object of type 'System.Object' to type (MyClass) Vb.Net

Can't import System.Net.Http on VB.Net page

Getting System.OverflowException using GroupBy and anonymous class