StringBuilder.Replace Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Gast

    #1

    StringBuilder.Replace Problem

    Wieso wird beim folgenden Code nicht das Ergebnis ...drei Schwe...
    geliefert? Startindex 5 statt 6 ändert auch nichts am Ergebnis.

    Dim sb As New System.Text.Str ingBuilder("hab e zwei Schweine und zwei
    Hühner")
    sb.Replace("zwe i", "drei", 6, 1)
    MsgBox(sb.ToStr ing)


    Danke Peter


  • pvdg42

    #2
    Re: StringBuilder.R eplace Problem


    "Peter Gast" <peter.gast@tis cali.dewrote in message
    news:enlgth$d9e $1@online.de...
    Wieso wird beim folgenden Code nicht das Ergebnis ...drei Schwe...
    geliefert? Startindex 5 statt 6 ändert auch nichts am Ergebnis.
    >
    Dim sb As New System.Text.Str ingBuilder("hab e zwei Schweine und zwei
    Hühner")
    sb.Replace("zwe i", "drei", 6, 1)
    MsgBox(sb.ToStr ing)
    >
    >
    Danke Peter
    >
    Perhaps this article will help:

    http://msdn2.microsoft.com/en-us/library/y1bxd041.aspx

    Above, change sb.Replace("zwe i", "drei", 6, 1)
    to sb.Replace("zwe i", "drei", 5, 4) and it works.


    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: StringBuilder.R eplace Problem

      "Peter Gast" <peter.gast@tis cali.deschrieb:
      Wieso wird beim folgenden Code nicht das Ergebnis ...drei Schwe...
      geliefert? Startindex 5 statt 6 ändert auch nichts am Ergebnis.

      In addition to the other replies, note that this newsgroup targets the
      English language. The German group's name is
      "microsoft.publ ic.de.german.en twickler.dotnet .vb".

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

      Comment

      Working...