Microsoft.VisualBasic.Replace bug

  • Thread starter Harry F. Harrison
  • Start date
H

Harry F. Harrison

In VS 2003, If an empty string is passed into the 1st parameter, the Replace
function returns Nothing.

Example:

Dim strResults As String = ""
strResults = Microsoft.VisualBasic.Replace("", "AND", "And", , ,
CompareMethod.Binary)

looking at strResults in the debugger shows it having a value of nothing
after executing the Replace function.

The documentation specifically says that it should return an empty string.

Return Values
Replace returns the following values:

If Replace returns
Expression is zero-length Zero-length string ("")
Find is zero-length Copy of Expression
Replace is zero-length Copy of Expression with no occurrences of Find
Start is greater than length of expression Zero-length string
Count is 0 Copy of Expression
 
H

Herfried K. Wagner [MVP]

Harry F. Harrison said:
In VS 2003, If an empty string is passed into the 1st parameter, the
Replace function returns Nothing.

Example:

Dim strResults As String = ""
strResults = Microsoft.VisualBasic.Replace("", "AND", "And", , ,
CompareMethod.Binary)

looking at strResults in the debugger shows it having a value of nothing
after executing the Replace function.

The documentation specifically says that it should return an empty string.

Yes, this is a bug in the implementation. Unfortunately Microsoft decided
to change the method specification instead of fixing the implementation in
VB 2005:

Check out this discussion:

<URL:http://groups.google.de/group/micro...nguages.vb/browse_frm/thread/41cbc41c1c2331ac>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top