Converts string to 32-bit signed integer equivalent
Module StringParsing
Public Sub Main()
TryToParse(Nothing)
TryToParse("16,667")
End Sub
Private Sub TryToParse(value As String)
Dim number As Integer
Dim result As Boolean = Int32.TryParse(value, number)
If result Then
Console.WriteLine("Converted '{0}' to {1}.", value, number)
Else
If value Is Nothing Then value = ""
Console.WriteLine("Attempted conversion of '{0}' failed.", value)
End If
End Sub
End Module
Related examples in the same category