Mega Code Archive

 
Categories / VB.Net Tutorial / Data Type
 

Parse(String) method converts an array of strings to equivalent Single values

Module Example    Public Sub Main()       Dim values() As String = { "100", "(100)", "-123,456,789", "123.45e+6", _                                 "-Infinity", "-1E-16", 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