Link to home
Create AccountLog in
Avatar of mpdillon
mpdillon

asked on

Difference between Replace Function and Method

I am using Visual Basic 2008. I get different results using the REPLACE function than when i use the REPLACE method.

In the following code I am trying to replace every occurrence of "<ul>" with the ASCII character no 134.

Method - does not make any replacements
HTMLTextString.Replace("<ul>", Chr(134))

Function - Behaves as expected. It replaces all the occurrences of <ul> with chr(134)
HTMLTextString = Replace(HTMLTextString, "<ul>", Chr(134))

Would someone please explain.
thanks,
pat
Avatar of mpdillon
mpdillon

ASKER

HTMLTextString = HTMLTestString.replace("<ul>", chr(134))

This works fine. But why do I need to make HTMLTextString = to the method. Please explain.
ASKER CERTIFIED SOLUTION
Avatar of Zhaolai
Zhaolai
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
The definition of String.Replace from MSDN:

Returns a new string in which all occurrences of a specified Unicode character or String in the current string are replaced with another specified Unicode character or String.
Thank you