简体   繁体   中英

VB.net Convert String to Integer with high value

I am using VB.net I Need Help what I want is for it to convert the string to integer as shown.

    Dim txt12(7) As String

    Dim txt12toint As Integer
    txt12(0) = "048048048048"
    If txt12(0).Substring(0, 1) = 0 Then
        txt12(0) = txt12(0).Substring(1, 11)
    End If
    txt12toint = Convert.ToInt64(txt12(0))

However there is always a message stating : OverflowException was unhandled arithmetic operation resulted in an overflow Makesure you are not dividing by zero

I even tried:

Cint(txt12(0))

and

Convert.toint32(txt12(0))

but the error to this is the characters are either too long or too short. because int32 is up to 2,147,483,647 one Please if anyone can help thank you in advance

Just declare txt12toint as Long:

Dim txt12toint As Long

This is because 48048048048 exceeds the maximum value for an Integer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM