String.Replace() in VB.NET
String.Replace() method used to put new string in the place of another string.
String.Replace() method used to put new string in the place of another string. String.Replace () method take two argument. First argument take old value of string and second argument take new value of string.
Syntax
String.Replace (string1, string2)
|

Module Module1
Sub Main()
Dim userInput As String = "My name is Clark. I am living in Cape Town in South Africa" & vbLf & vbLf
Console.WriteLine(userInput)
Console.WriteLine("What do you want to change?")
Dim str1 As String = Console.ReadLine()
Console.WriteLine("Enter your new value:")
Dim str2 As String = Console.ReadLine()
userInput = userInput.Replace(str1, str2)
Console.WriteLine(userInput)
Console.WriteLine("What do you want to change?")
str1 = Console.ReadLine()
Console.WriteLine("Enter your new value:")
str2 = Console.ReadLine()
userInput = userInput.Replace(str1, str2)
Console.WriteLine(userInput)
Console.ReadLine()
End Sub
End Module
Output
