Name

Replace Function — Microsoft.VisualBasic.Strings

Synopsis

Replace(expression, find, replace [, start[, _
        count[, compare]]])
expression required; String

The complete string containing the substring to be replaced

find required; String

The substring to be found by the function

replace required; String

The new substring to replace find in expression

start optional; Long

The character position in expression at which the search for find begins

count optional; Long

The number of instances of find to replace

compare optional; CompareMethod constant

The method used to compare find with expression; its value can be CompareMethod.Binary (for case-sensitive comparison) or CompareMethod.Text (for case-insensitive comparison)

Return Value

The return value from Replace depends on the parameters you specify in the argument list, as the following table shows:

If

Return value

expression = “”

Zero-length string (“”)

find = “”

Copy of expression

replace = “”

Copy of expression with all instances of find removed

start > Len(expression)

Zero-length string (“”)

count = 0

Copy of expression

Description

Replaces a given number of instances of a specified substring in another string.

Get VB.NET Language Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.