Private Sub Command1_Click()
Dim I As Integer, S As String
S = "1 2 6 7 9"
For I = Len(S) To 2 Step -1
S = Replace(S, Space(I), Space(1))
Next
MsgBox S
End Sub
dim str as string
dim strTemp as string
dim i as integer
'模拟c的做法
str="a b c"
strTemp=left(str,1)
i=2
while i<=len(str)
if mid(str,i,1)="" then '空格
if(right(strTemp,1)<>"") then 'strtemp的最后一个不是空格
strTemp=strTemp & mid(str,i,1)
end if
else
strTemp=strTemp & mid(str,i,1)
end if
i=i+1
wend