Boolean.Parse converts string to Boolean
Module Example
Public Sub Main()
Dim values() As String = { Nothing, String.Empty, "True", "False",
"true", "false", " true ", "0",
"1", "-1", "string" }
For Each value In values
Try
Dim flag As Boolean = Boolean.Parse(value)
Console.WriteLine("'{0}' --> {1}", value, flag)
Catch e As ArgumentException
Console.WriteLine("Cannot parse a null string.")
Catch e As FormatException
Console.WriteLine("Cannot parse '{0}'.", value)
End Try
Next
End Sub
End Module
Related examples in the same category