Thursday, October 30, 2014

How to replace certain letters in a string

Try this:



Dim pass As String = "Chipotle"
Dim pass2 As String = pass.Replace("o", "0").Replace("t", "7").Replace("l", "1").Replace("e", "3")
MessageBox.Show(pass2)



Note that the Replace method is case sensitive. If you want both upper case "O" and lower case "o" to be changed to number "0", you will need two calls to Replace: Replace("O", "0").Replace("o", "0")

No comments:

Post a Comment