Mega Code Archive

 
Categories / VB.Net / Data Types
 

Parse string to Integer

Imports System.Globalization Module Example    Public Sub Main()         Dim string1 As String = "9999"         Try            Dim number1 As Integer = Int32.Parse(string1)            Console.WriteLine(number1)         Catch e As OverflowException            Console.WriteLine("'{0}' is out of range of a 32-bit integer.", string1)         Catch e As FormatException            Console.WriteLine("The format of '{0}' is invalid.", string1)         End Try    End Sub End Module