SByte.Parse converts string in a style to 8-bit signed integer equivalent.
Imports System.Globalization
Module Example
Public Sub Main()
Dim style As NumberStyles
Dim number As SByte
Dim values1() As String = { " 121 ", "121", "-121" }
style = NumberStyles.None
Console.WriteLine("Styles: {0}", style.ToString())
For Each value As String In values1
Try
number = SByte.Parse(value, style)
Console.WriteLine(" Converted '{0}' to {1}.", value, number)
Catch e As FormatException
Console.WriteLine(" Unable to parse '{0}'.", value)
End Try
Next
End Sub
End Module
Related examples in the same category