469,883 Members | 1,219 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,883 developers. It's quick & easy.

Hope this is a bug in "Replace"

Private NameLastFirst as object = "Public, John Q."

NameLastFirst = Replace(LastName, "'", "''")

If NameLastFirst contains "Public, John Q." before the above Replace, it
will contain "Public" after the Replace. At least that's how it's working
in my version of VS.NET. That does not seem right to me. Am I missing
something?

Note that the replacement character(s) are *apostrophes*, not *commas*

Thanks for looking,

Dean Slindee
Nov 20 '05 #1
6 1144
"Dean Slindee" <sl*****@charter.net> schrieb
Private NameLastFirst as object = "Public, John Q."

NameLastFirst = Replace(LastName, "'", "''")

If NameLastFirst contains "Public, John Q." before the above Replace,
it will contain "Public" after the Replace. At least that's how it's
working in my version of VS.NET. That does not seem right to me. Am
I missing something?

Note that the replacement character(s) are *apostrophes*, not
*commas*


What is the content of variable LastName? You didn't mention this.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
* "Dean Slindee" <sl*****@charter.net> scripsit:
Private NameLastFirst as object = "Public, John Q."

NameLastFirst = Replace(LastName, "'", "''")

If NameLastFirst contains "Public, John Q." before the above Replace, it
will contain "Public" after the Replace. At least that's how it's working
in my version of VS.NET. That does not seem right to me. Am I missing
something?

Note that the replacement character(s) are *apostrophes*, not *commas*


I am not able to repro that using this code on VB 2003:

\\\
Dim NameLastFirst As String = "Public, John Q."
NameLastFirst = Replace(NameLastFirst, "'", "''")
MsgBox(NameLastFirst)
///

Why do you declare 'NameLastFirst' as 'Object' and not as 'String'?

Why do you replace in 'LastName' and not in 'NameLastFirst'?

What is 'LastName'?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
Herfried,
Congrats, you caught the error, and it is mine.
NameLastFirst = Replace(LastName, "'", "''")
should read:
NameLastFirst = Replace(NameLastName, "'", "''")
(I am running parallel name fields in preparation for a conversion, normally
would have only one set of names and this error would never come into play.)

NameLastFirst was declared as an Object because it could be null and I
wanted to preserve the null value when writing it out to the new database.

Thank you.
Dean Slindee
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2i************@uni-berlin.de...
* "Dean Slindee" <sl*****@charter.net> scripsit:
Private NameLastFirst as object = "Public, John Q."

NameLastFirst = Replace(LastName, "'", "''")

If NameLastFirst contains "Public, John Q." before the above Replace, it
will contain "Public" after the Replace. At least that's how it's working in my version of VS.NET. That does not seem right to me. Am I missing
something?

Note that the replacement character(s) are *apostrophes*, not *commas*


I am not able to repro that using this code on VB 2003:

\\\
Dim NameLastFirst As String = "Public, John Q."
NameLastFirst = Replace(NameLastFirst, "'", "''")
MsgBox(NameLastFirst)
///

Why do you declare 'NameLastFirst' as 'Object' and not as 'String'?

Why do you replace in 'LastName' and not in 'NameLastFirst'?

What is 'LastName'?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #4
Hi Dean,
Herfried,
Congrats, you caught the error, and it is mine.
NameLastFirst = Replace(LastName, "'", "''")
should read:


Why you only congrats Herfried, while Armin made us attent on this before
Herfried?

Cor
Nov 20 '05 #5
* "Dean Slindee" <sl*****@charter.net> scripsit:
Congrats, you caught the error, and it is mine.
NameLastFirst = Replace(LastName, "'", "''")
should read:
NameLastFirst = Replace(NameLastName, "'", "''")
(I am running parallel name fields in preparation for a conversion, normally
would have only one set of names and this error would never come into play.)

NameLastFirst was declared as an Object because it could be null and I
wanted to preserve the null value when writing it out to the new database.


Then don't forget to turn 'Option Strict' on...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #6
I think I was ready replies from the bottom up. Congrats to Armin is in
order too!
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:uA**************@TK2MSFTNGP10.phx.gbl...
Hi Dean,
Herfried,
Congrats, you caught the error, and it is mine.
NameLastFirst = Replace(LastName, "'", "''")
should read:


Why you only congrats Herfried, while Armin made us attent on this before
Herfried?

Cor

Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by vigi98 | last post: by
3 posts views Thread by asd987 | last post: by
6 posts views Thread by Marty | last post: by
8 posts views Thread by bsonline | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.