Removes duplicate spaces within strings.


In Visual Basic On click event write the code.

Public Function SquishSpaces( ByVal strText As String ) As String

Const TWO_SPACES As String = " "

Dim intPos As Integer
Dim strTemp As String

intPos = InStr(1, strText, TWO_SPACES, vbBinaryCompare)
Do While intPos > 0
strTemp = LTrim$(Mid$(strText, intPos + 1))
strText = Left$(strText, intPos) & strTemp
intPos = InStr(1, strText, TWO_SPACES, vbBinaryCompare)
Loop

SquishSpaces = strText 

End Function




Added on June 1, 2007 Comment
}