Need help with removing spaces
Hi, I have some strings which have spaces at the end of them. I want to remove the spaces by going backwards. My code:
Code:
For num = s.Length To 0 Step -1
If Mid(s, num - 1, num) = " " Then
Console.WriteLine("Removing space")
s = s.Remove(num - 1, 1)
Else
Exit For
End If
Next
My code can't delete the characters and doesn't output "Removing space". Can anyone help me?
Re: Need help with removing spaces
Anyway, I fixed this by code:
Code:
Dim lastWord As String = s.Split("+").Last
s = s.Replace(lastWord, "")
Re: Need help with removing spaces