Replacing string character

J

John

Hi

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

Thanks

Regards
 
T

Travis Sharpe

John said:
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 "$"
 
D

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.
 
H

Herfried K. Wagner [MVP]

John said:
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'.
 

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