projecttoday
Programmer
Is there any way of converting multiple blanks in a string between words to just one blank?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[blue]Public Function TrimSpaces(ByVal Dat As String) As String
Do Until InStr(1, Dat, " ") = 0
Dat = Replace(Dat, " ", " ")
Loop
TrimSpaces = Dat
End Function[/blue]
Public Function ReplaceSpaces(strInput As String) As String
Dim re As Object
Set re = CreateObject("VBScript.RegExp")
With re
.Global = True
.MultiLine = True
.IgnoreCase = True
.Pattern = "\s{2,}"
ReplaceSpaces = .Replace(strInput, " ")
End With
Set re = Nothing
End Function