Reputation: 2771
Using VB6 without any additional references such as Regex, how can I convert a string so that all whitespace in a string is reduced to single spaces?
eg.
" A B C D E"
would be converted to
"A B C D E"
Upvotes: 1
Views: 3210
Reputation: 2771
Function NormalizeSpaces(s As String) As String
Do While InStr(s, String(2, " ")) > 0
s = replace(s, String(2, " "), " ")
Loop
NormalizeSpaces = s
End Function
(derived from: http://www.techrepublic.com/article/normalizing-spaces-in-vb6-strings/5890164)
Upvotes: 5