Re: Replace function doesn't work properly



Co <vonclausowitz@xxxxxxxxx>'s wild thoughts were released
on Tue, 21 Oct 2008 00:20:59 -0700 (PDT) bearing the
following fruit:

On 20 okt, 15:16, "Jeff Johnson" <i....@xxxxxxxxxxx> wrote:
"Co" <vonclausow...@xxxxxxxxx> wrote in message

news:649f8e98-e803-4639-9e69-0f82df0e6754@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I use the Replace function in a vb project but found out that it ain't
working properly.
I try to remove a space from a string using:

sStr = Replace(sStr, " ", "",1, -1)

I tried this, and with Chr(32) and also vbBinaryCompare.
The space stays in.

Any ideas what causes this?

Chr$(160) instead of a normal space.

All,

I created a function to check all the characters in the string and it
definitely comes up with a Chr(32).
Still the Replace function won't remove it.
Does it have to do with the fact that I use this in VBA Word office
2003?

Well that is a *VERY* important piece of information because
VB6 solutions won't always work in VBA.

However in this case it shouldn't make a difference.

Can you post the string here?

J



sFinalName = Replace(sFinalName, Chr(46) & Chr(32) & Chr(46), ".",
1, -1, vbTextCompare)
findchrs (sFinalName)


Public Function findchrs(str As String)

Dim i As Integer
Dim j As Integer
Dim sResult As String

i = 1
j = Len(str)
Do While i < j
sResult = sResult & Asc(Mid(str, i, 1)) & ","
i = i + 1
Loop
Debug.Print str
Debug.Print sResult

End Function

--
Jan Hyde (VB MVP)

https://mvp.support.microsoft.com/profile/Jan.Hyde
.



Relevant Pages

  • Search pattern
    ... Dim strfile As String ... Dim bAddressFound As Boolean ... Dim strCurrentChar As String ...
    (comp.databases.ms-access)
  • Auto Write Name and Merge across
    ... Dim Sheetname01 As String ... Dim WeekName01 As String ...
    (microsoft.public.excel.misc)
  • Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
    ... Friend Versione As String ... Public Sub GetMyConnectionPalmare() ... Dim errorMessages As String ... Private Function GetDS_Desktop(ByVal SQL As String) As DataSet ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
    ... Friend Versione As String ... Public Sub GetMyConnectionPalmare() ... Dim errorMessages As String ... Private Function GetDS_Desktop(ByVal SQL As String) As DataSet ...
    (microsoft.public.dotnet.framework.compactframework)
  • Help answer these 70-310 questions
    ... One argument is the string ... Dim output As New StringBuilder ... EmployeeLocations. ... You create a strongly named serviced component. ...
    (microsoft.public.cert.exam.mcsd)