-
Oct 20th, 2009, 01:52 PM
#1
Thread Starter
New Member
[RESOLVED] Replace string value in a string
Dear all,
i'm trying to make the following code work... but, something not understandable happens, ie when i'm trying to replace "01" in the the string "01020304050607080910111213", it doesn't only remove the "01" at the beginning but the "10" in the middle ??? Can anyone help ?
Sub toto1()
Dim valuetoreplace As String
valuetoreplace = "01"
Dim myval As String
myval = "01020304050607080910111213"
Dim mynewval As String
mynewval = Replace(myval, valuetoreplace, "")
Debug.Print mynewval
End Sub
Thanks in advance for any help !
-
Oct 20th, 2009, 02:01 PM
#2
Fanatic Member
Re: Replace string value in a string
did you add Option Explicit in the top of the code?
-
Oct 20th, 2009, 02:12 PM
#3
Thread Starter
New Member
Re: Replace string value in a string
Hi, thanks for the reply but no. Unfortunately, that doesn't solve the problem either. I really don't get it...
-
Oct 20th, 2009, 02:23 PM
#4
Hyperactive Member
Re: Replace string value in a string
You have two "01"
Code:
"01"..............."01"
myval = "01020304050607080910111213"
"01020304050607080910111213"
'01'02030405060708091'01'11213
Last edited by 5ms?; Oct 20th, 2009 at 05:22 PM.
Reason: To say You're welcome
-
Oct 20th, 2009, 02:31 PM
#5
Thread Starter
New Member
Re: [RESOLVED] Replace string value in a string
Gosh i'm stupid... of course... Too many hours in front of the pc... Thanks a lot, 5ms? (as well as to justa lol).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|