The final .... (probably)
Now it is actually does what it should.
Any input combination is handled as it is supposed to.
Even an an input like this is separated in the manner it should.
whereinput = "Cold street 123 A 123 45"
Output:
Cold street 123 A
123 45
I have played a bit with the index and the values stays at the same index positions but are placed into different variables.
Everything seems to work. I still have one piece left, and that is the cityname that can appear at the very end of the string or by it's own. I havn't figured that out yet, and hopefully I get some help with that.
The streetname alone or a cityname alone should populate a variable named hybrid.
If there is any spaces in that string the first substring populate streetname second substring the hybrid variable.
whereinput = "Cold street 123 A 123 45"
whereinput = Trim(whereinput)
where = Split(whereinput, " ")
For i = 0 To UBound(where)
If i = 0 AND i = Ubound(where) AND IsNumeric(where) = False Then
hybrid = where(i)
ElseIf i = 0 AND i < Ubound(where) AND IsNumeric(where) = False Then
streetname = where(i)
ElseIf i = 1 AND i < Ubound(where) AND IsNumeric(where) = False Then
streetname = where(i)
ElseIf i = 2 AND i < Ubound(where) AND IsNumeric(where) = False Then
streetname = where(i)
ElseIf i = 3 AND i < Ubound(where) AND IsNumeric(where) = False Then
streetname = where(i)
ElseIf i = 4 AND i < Ubound(where) AND IsNumeric(where) = False Then
streetname = where(i)
End If
If i = Ubound(where) AND IsNumeric(Left(where(i),1)) = True AND Len(where(i)) < 5 Then
If i = 1 Then
streetname = streetname&" "&where(i)
End If
If i = 2 Then
streetname = where(i-2)&" "&streetname&" "&where(i)
End If
If i = 3 Then
streetname = where(i-3)&" "&where(i-2)
End If
If i = 4 Then
streetname = where(i-4)&" "&where(i-3) & " " &where(i-2)
End If
If i = 5 Then
streetname = where(i-5)&" "&where(i-4) & " " &where(i-3) & " " & where(i-2)
End If
If i = 6 Then
streetname = where(i-6)&" "&where(i-5) & " " &where(i-4) & " " & where(i-3)
End If
Response.Write(i &" = " & streetname & "<br>")
End If
If i = Ubound(where) AND IsNumeric(Left(where(i),1)) = False Then
If i = 6 Then
streetname = where(i-6)&" "&where(i-5) & " " &where(i-4) & " " & where(i-3)
End If
If i = 5 Then
streetname = where(i-5)&" "&where(i-4) & " " &where(i-3) & " " & where(i-2)
End If
If i = 4 Then
streetname = where(i-4)&" "&where(i-3) & " " & where(i-2)
End If
If i = 3 Then
streetname = where(i-3)&" "&where(i-2)
End If
If i = 2 Then
streetname = streetname & " " &where(i)
End If
If i = 1 Then
streetname = streetname & " " &where(i)
End If
Response.Write(i &" = " & streetname & "<br>")
Response.Write(i &" = " & hybrid & "<br>")
End If
If i = Ubound(where) AND IsNumeric(Left(where(i),1)) = True AND Len(where(i)) = 5 Then
If i = 0 Then
zipcode = where(i)
End If
If i = 1 Then
streetname = where(i-1)
zipcode = where(i)
End If
If i = 2 Then
streetname = where(i-2) &" "& where(i-1)
zipcode = where(i)
End If
If i = 3 Then
streetname = where(i-3) &" "& where(i-2) &" "& where(i-1)
zipcode = where(i)
End If
If i = 4 Then
streetname = where(i-4) &" "& where(i-3) &" "& where(i-2) &" "& where(i-1)
zipcode = where(i)
End If
If i = 5 Then
streetname = where(i-5) &" "& where(i-4) &" "& where(i-2) &" "& where(i-1)
zipcode = where(i)
End If
Response.Write(i &" = " & streetname & "<br>")
Response.Write(i &" = " & zipcode & "<br>")
ElseIf i = Ubound(where) AND IsNumeric(Left(where(i),2)) = True AND Len(where(i)) = 2 Then
If i = 4 Then
streetname = where(i-4) &" "& where(i-3) &" "& where(i-2)
zipcode = where(i)
End If
If i = 3 Then
streetname = where(i-3) &" "& where(i-2)
zipcode = where(i-1)&where(i)
End If
If IsNumeric(Left(where(i-1),3)) = True AND Len(where(i-1)) = 3 Then
If i = 2 Then
streetname = where(i-2) '&" "& where(i-1)
zipcode = where(i-1)&where(i)
End If
End If
zipcode = where(i-1) & where(i)
Response.Write(i &" = " & zipcode & "<br>")
End If
Next
Response.Write("<br>")
Response.Write("streetname: " & streetname) & "<br>"
Response.Write("zipcode: " & zipcode) & "<br>"
Response.Write("hybrid: " & hybrid)