Home All Groups Group Topic Archive Search About

Replacing string character

Author
10 Jul 2006 7:09 PM
John
Hi

How can I replace all occurrences of a character in a string to another
character?

Thanks

Regards

Author
10 Jul 2006 7:19 PM
Travis Sharpe
John wrote:
> Hi
>
> How can I replace all occurrences of a character in a string to another
> character?
>
> Thanks
>
> Regards
>
>
Use the .Replace method of the string
..Replace("char that will be replaced","char to replace original char")

Dim temp as string = "ThisStringIsATest"
Dim result as string = temp.Replace("T","$")
'Replaces every occurence of "T" with "$"
Author
10 Jul 2006 7:23 PM
Dick Grier
Hi,

It may sound silly, but...

Try the string's Replace method.  Example:

    Buffer = Buffer.Replace(comecharsequence, someothercharsequence)

Dick
--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
Author
10 Jul 2006 8:11 PM
Herfried K. Wagner [MVP]
"John" <John@nospam.infovis.co.uk> schrieb:
> How can I replace all occurrences of a character in a string to another
> character?

'System.String.Replace', 'Microsoft.VisualBasic.Strings.Replace',
'System.Text.RegularExpressions.Regex.Replace'.

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