Mega Code Archive

 
Categories / VB.Net / Data Types
 

SByte Parse converts string number to 8-bit signed integer

Module Example    Public Sub Main()         Dim values() As String = { "  12  ", "+120", "(103)", "192", "-160" }                  For Each value As String In values            Try               Console.WriteLine("Converted '{0}' to the SByte value {1}.",value, SByte.Parse(value))            Catch e As FormatException               Console.WriteLine("'{0}' cannot be parsed successfully by SByte type.",value)            Catch e As OverflowException               Console.WriteLine("'{0}' is out of range of the SByte type.",value)            End Try                                                                                 Next             End Sub End Module