By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,504 Members | 1,212 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,504 IT Pros & Developers. It's quick & easy.

Remove Spaces

P: n/a
I try to remove the spaces with that method but it still dont work.
When i run in the debug mode it still shows spaces.

If (bCorpFound) Then
strCorp = LTrim(strCorp)
strCorp = RTrim(strCorp)
strCorp = Replace(strCorp, " ", "")
' strCurrentChar = Right(strCorp, 1)
' Do While (strCurrentChar = " ")
' Advance 1 char, from right
' strCorp = Left(strCorp, (Len(strCorp) - 1))
' strCurrentChar = Right(strCorp, 1)
' Loop
End If

Thank You.

Aug 21 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
just use Replace.
?replace(" Text With Lots Of Spaces"," ","")
TextWithLotsOfSpaces

Aug 21 '06 #2

P: n/a
Or better, try this:

Public Function RemoveExtraSpaces(ByVal strText As String) As String
'--Debug.Print "-" & strText & "-"
Do Until InStr(1, strText, " ") = 0
strText = Replace(strText, " ", " ")
Loop
'--Debug.Print "-" & strText & "-"
End Function

?removeextraspaces(" My Text With Lots Of Spaces ")
- My Text With Lots Of Spaces -
- My Text With Lots Of Spaces -

Aug 21 '06 #3

P: n/a
co*********@gmail.com wrote:
I try to remove the spaces with that method but it still dont work.
When i run in the debug mode it still shows spaces.

If (bCorpFound) Then
strCorp = LTrim(strCorp)
strCorp = RTrim(strCorp)
strCorp = Replace(strCorp, " ", "")
' strCurrentChar = Right(strCorp, 1)
' Do While (strCurrentChar = " ")
' Advance 1 char, from right
' strCorp = Left(strCorp, (Len(strCorp) - 1))
' strCurrentChar = Right(strCorp, 1)
' Loop
End If

Thank You.
Maybe this is the problem:

http://groups.google.com/group/comp....8e898050f165ea

James A. Fortune
CD********@FortuneJames.com

Aug 21 '06 #4

P: n/a
L.S.

There are even more flavours of spaces within the unicode-characterset
that is used within MS-Access internally. Probably the
comparision-method parameter of the replace-function will help when not
using the binary or database method, but using the text-method.
Sometimes when working on non-access database-tables blank-padding
occurs automatically, optionally or even mandatory. This also occurs
when declaring string variables with a fixed length within VBA. May be
that's the problem ..

Marc

CD********@FortuneJames.com schreef:
co*********@gmail.com wrote:
I try to remove the spaces with that method but it still dont work.
When i run in the debug mode it still shows spaces.

If (bCorpFound) Then
strCorp = LTrim(strCorp)
strCorp = RTrim(strCorp)
strCorp = Replace(strCorp, " ", "")
' strCurrentChar = Right(strCorp, 1)
' Do While (strCurrentChar = " ")
' Advance 1 char, from right
' strCorp = Left(strCorp, (Len(strCorp) - 1))
' strCurrentChar = Right(strCorp, 1)
' Loop
End If

Thank You.

Maybe this is the problem:

http://groups.google.com/group/comp....8e898050f165ea

James A. Fortune
CD********@FortuneJames.com
Aug 21 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.