[ 本帖最后由 afterain 于 2007-11-14 11:29 编辑 ]作者: fan0217 时间: 2007-11-14 12:14
那就再替换啊,最直接的方法。作者: wanshan 时间: 2007-11-14 12:30
要用到循环:
Public Function kongge(str As String) As String
Do Until InStr(str, " ") = 0
str = Replace(str, " ", " ")
Loop
kongge = str
End Function
调用:kongge(str)作者: andymark 时间: 2007-11-14 14:18
也可用SPLIT分割后合并
Public Function MySplit(Str As String) As String
Dim vArr As Variant
Dim astr(10) As String
vArr = astr
vArr = Split(Str, " ")
Str = ""
For i = LBound(vArr) To UBound(vArr)
If vArr(i) <> "" Then
Str = Str & vArr(i) & Space(1)
End If
Next i
MySplit = Trim(Str)