Replace Function in VB.NET

How to replace occurences of string using replace function?

Explanation

String Replace in VB.NET

Replace Function in Visual Basic.net is used to replace a substring by another substring, the specified number of times in a string.
Syntax:

Function Replace( ByVal Expression As String,
ByVal Find As String, ByVal Replacement As String) As String

In the above syntax String specifies the string to find the substring specified in Find and replace it with the substring specified in Replacement.
Example:

Module Module1
Sub Main()
Console.WriteLine("String replaced with oo is:: " &
Replace("World xx Wide xx Web xx", "x", "o"))
Console.ReadLine()
End Sub
End Module
Result:

String replaced with oo is:: World oo Wide oo Web oo

In the above replace function example, the substring 'xx' are replaced with the substring 'oo'.

Visual Basic Tutorial


Ask Questions

Ask Question