Why do I get Conversion from string "" to type 'Integer' is not valid.? Match is a string, and when I compare it to "" it gives me this error. The program works when values are entered etc. but if I want to check for an empty string (the last ElseIf) I get an error.
Dim total As Double
Dim Match As String = ""
If Match.EndsWith("HA") OrElse Match.Contains("ha") OrElse Match.Contains("Ha") Then
Dim nonNumericCharacters As New Regex("\D")
Dim numericOnlyString As String = nonNumericCharacters.Replace(Match, String.Empty)
total = numericOnlyString * 10000
ElseIf Match.Contains("Ha m²") Then
Dim nonNumericCharacters As New Regex("\D")
Dim numericOnlyString As String = nonNumericCharacters.Replace(Match, String.Empty)
total = numericOnlyString * 10000
ElseIf Match.Contains("m²") OrElse Match.Contains("sqm") Then
Dim nonNumericCharacters As New Regex("\D")
Dim numericOnlyString As String = nonNumericCharacters.Replace(Match, String.Empty)
total = Val(numericOnlyString)
ElseIf CInt(Match) = 0 OrElse Match = "" Then
total = Val(String.Empty)
Else
total = Match
End If
MessageBox.Show(total)
""is not a number. You should reorder the expression to:((Match = "") OrElse (CInt(Match) = 0))