check out this function written by a Sr. Dev where I work, he could have user Replace(str,"'","''")
'Description: This function returns the passed string with single quote(')
'characters replaced with two single quote characters. Prepares the
'string to be used as part of a RowFilter expression.
' QuoteForFilter("PIG'S FEET") returns "PIG''S FEET"
Private Function QuoteForFilter(ByVal criteria As String) As String
Dim alCharBuffer As New System.Collections.ArrayList(criteria.Length)
Dim c As Char
For Each c In criteria
If c = "'"c Then
Return New String(CType(alCharBuffer.ToArray(GetType(Char)), Char()))
We've got a boatload of code where I work that exhibits this
quality. I stripped a good deal of it out a couple of years ago,
but our most persistent offender (used in far too many places to
remove) is CopyChars().
Okay, but you have to get your coffee and settle into your easy chair and read the reference from front to back. Either that or study all of the "What's new?" section of the documentation. You can't just go looking up new keywords by intuiting them.
Imagine our author above, moving from VB5 to VB6 and hoping they've added a character removal routine, so he does a search on "stripChar", "charStrip", "charRemove", "stringRemove", "charDelete", and any other targets he can think of that would describe removing a character from a string. But because he's trying to remove a character, not swap it for something else, it never occurs to him to look for "replace".
That's a good theory, except that googling for "vb6 remove characters from string" gives you this as the first result: http://www.codeguru.com/vb/gen/vb_misc/text/article.php/c2739/
Google. It's like the ultimate reference manual.
I wonder if he wrote his solution faster than you could implement something you found via a search engine.
Reinventing the wheels isn't necessarily a bad thing to do.
In some languages, like AS3, building your own version of built-in methods can be very useful, especially if you're looking for soem performance improvements.
A good example of this would be to inline your own version of Math.abs() or pretty much anything of the Math class.
Not having to call the method from an external class and doing some improvements (like building some bitwise hell) can result in a method that returns the same than the built-in one, but that will also run hundreds (and sometimes thousands) of times faster.