使用VB6 而不用任何其他引用(如Regex),如何转换字符串以便字符串中的所有空格都缩减为单个空格?
例如
" A B C D E"
将转换为
"A B C D E"
答案 0 :(得分:5)
Function NormalizeSpaces(s As String) As String
Do While InStr(s, String(2, " ")) > 0
s = replace(s, String(2, " "), " ")
Loop
NormalizeSpaces = s
End Function
(源自:http://www.techrepublic.com/article/normalizing-spaces-in-vb6-strings/5890164)