Re: Replace function doesn't work properly
- From: Robert Morley <rmorley@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 21 Oct 2008 04:11:58 -0400
Co wrote:
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'tChr$(160) instead of a normal space.
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?
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?
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
Everything looks good in your code as far as I can see. Can you cut & paste the string you're using for sFinalName, just so we can all be 100% sure of what's going on? Or better yet, the output from findchrs?
Oh and to answer your question, while it's conceivable that the VBA in Word 2003 is different, it's rather unlikely, as VB6 and VBA are both ultimately based on the same thing, with relatively minor variations for the most part, and I'm 99.999% (add a few more 9's for good measure) sure that Replace isn't one of them. Therefore, it seems most likely that either there's a problem with your source string, or there's a problem with the code that nobody's seeing (like if you used a hard space in the code, as opposed to the original string).
Rob
.
- References:
- Replace function doesn't work properly
- From: Co
- Re: Replace function doesn't work properly
- From: Jeff Johnson
- Re: Replace function doesn't work properly
- From: Co
- Replace function doesn't work properly
- Prev by Date: Re: Access 2007 and VB
- Next by Date: Re: Add a context menu item to Windows Explorer (Win98) with VB6?
- Previous by thread: Re: Replace function doesn't work properly
- Next by thread: Re: Replace function doesn't work properly
- Index(es):
Relevant Pages
|
Loading