Question : modify vbs code to reduce multiple continuous spaces to one space

The following code formats a text file to a CSV. Can it be modified so that any groups of continuous spaces embedded in the fields are reduced to one space?
(i.e. "How     are   you" to "How are you")

Set objFSO = CreateObject("Scripting.FileSystemObject")
myFile = "c:\macros\aces\claim13.txt"
Set objFile = objFSO.OpenTextFile(myFile,1)
Do Until objFile.AtEndOfStream
  line=objFile.ReadLine
  WScript.Echo Trim(Mid(line,1,2)) & "," & Trim(Mid(line,3,2)) & "," & Trim(Mid(line,5,200))
Loop
Function Trim0(s)
  While Left(s,1) = "0" AND s <> ""
    s = Right(s,Len(s)-1)
  Wend
  Trim0 = s
End Function

Answer : modify vbs code to reduce multiple continuous spaces to one space

I'd do something like:

    Do While InStr(str, "  ") > 0
        str = Replace(str, "  ", " ")
    Loop

Chris
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Set objFSO = CreateObject("Scripting.FileSystemObject") 
myFile = "c:\macros\aces\claim13.txt" 
Set objFile = objFSO.OpenTextFile(myFile,1) 
Do Until objFile.AtEndOfStream 
  line=objFile.ReadLine 
  WScript.Echo trimspace(line)
Loop 
Function trimspace(str As String) As String
    Do While InStr(str, "  ") > 0
        str = Replace(str, "  ", " ")
    Loop
    trimspace = str
End Function
Random Solutions  
 
programming4us programming4us