Microsoft.VisualBasic.Replace bug

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Harry F. Harrison

    #1

    Microsoft.VisualBasic.Replace bug

    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.Visua lBasic.Replace( "", "AND", "And", , ,
    CompareMethod.B inary)

    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


  • Herfried K. Wagner [MVP]

    #2
    Re: Microsoft.Visua lBasic.Replace bug

    "Harry F. Harrison" <harryh66@hotma il.comschrieb:
    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.Visua lBasic.Replace( "", "AND", "And", , ,
    CompareMethod.B inary)
    >
    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.d e/group/microsoft.publi c.dotnet.langua ges.vb/browse_frm/thread/41cbc41c1c2331a c>

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

    Comment

    Working...