Single.Parse Method converts string to single-precision floating-point number
Module Example
Public Sub Main()
Dim values() As String = { "100", "(100)", "-123,456,789", "123.45e+6", _
"-Infinity", "-1E-16", Double.MaxValue.ToString(), _
Single.MinValue.ToString(), String.Empty }
For Each value As String In values
Try
Dim number As Single = Single.Parse(value)
Console.WriteLine("{0} -> {1}", value, number)
Catch e As FormatException
Console.WriteLine("'{0}' is not in a valid format.", value)
Catch e As OverflowException
Console.WriteLine("{0} is outside the range of a Single.", value)
End Try
Next
End Sub
End Module
Related examples in the same category