Replace

concerns

The Replace function returns a string in which a specified child string with a specified frequency is replaced with another child string.

 

Syntax

Replace(Expr, SearchFor, ReplaceBy [, BeginAt [, Count [, Compare]]])

Return value

Type

Description

String

The result of string replacement

Parameter

Use

Name

Type

Passing

Description

Required

Expr

String

ByVal

String whose contents are to be partially replaced

Required

SearchFor

String

ByVal

Substring to replace

Required

ReplaceBy

String

ByVal

The replacement string

Optional

BeginAt

Long

ByVal

The position in SearchFor, from which the replacement is to take place

Optional

Count

Variant

ByVal

The number of replacements you want. If Count is not specified, all occurrences will be replaced

Optional

Compare

StrCompOption

ByVal

Type of comparison to identify a replacement position

 

Possible return values can be:

 

Return value

Description

""

Expr is an empty string or BeginAt > Length(Expr)

Expr

SearchFor is an empty string or count is 0

 

StrCompOption

Description

0

Binary comparison

1

Text-based comparison (case not included)

 

The Expr parameter passes the string that contains the child string to replace.

SearchFor contains the child string that Expr is searched for.

ReplaceBy is the child surrogate string.

If the BeginAt parameter is omitted, the search always starts from the first place. If you want to start the search from a different position, this parameter must be specified.

If the Count parameter is not defined, all found strings are replaced in Expr (default; Count = -1). Use this parameter to specify how many strings you want to replace.

Use the Compare parameter to specify the type of comparison.