MsYang
08-21-2006, 06:07 AM
I've attached a trimmed string example. The module will trim spaces in front of text, after the text and spaces between text that has 2 or more spaces.
It seems like whenever I need this code, I cant seem to find it anywhere, so thought I share it with everyone.
raskew
09-12-2006, 04:29 PM
Hi -
Like this?
Function OneSpace(pstr As String) As String
'*******************************************
'Purpose: Removes excess spaces from a string
'Input: ? onespace(" now is the time for all good men ")
'Output: "now is the time for all good men"
'*******************************************
Dim strHold As String
strHold = Trim(pstr)
Do While InStr(strHold, " ") > 0
strHold = Left(strHold, InStr(strHold, " ") - 1) & Mid(strHold, InStr(strHold, " ") + 1)
Loop
OneSpace = strHold
End Function
Bob