Name
Replace Function
Syntax
Replace(string,stringToReplace,replacementString[,start[,count[,compare]]])
-
string Use: Required
Data Subtype: String
The complete string containing the substring to be replaced.
-
stringToReplace Use: Required
Data Subtype: String
The substring to be found by the function.
-
replacementString Use: Required
Data Subtype: String
The new substring to replace
stringToReplaceinstring.-
start Use: Optional
Data Subtype: Long
The character position in
stringat which the search forstringToReplacebegins.-
count Use: Optional
Data Subtype: Long
The number of instances of
stringToReplaceto replace.-
compare Use: Optional
Data Subtype: Integer
The method that compares
stringToReplacewithstring; its value can bevbBinaryCompareorvbTextCompare.
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 |
|---|---|
|
|
Zero-length string (“”) |
|
|
An error |
|
|
Copy of |
|
|
Copy of |
|
|
Zero-length string (“”) |
|
|
Copy of |
Description
Replaces a given number of instances of a specified substring in another string.
Rules at a Glance
If
startis omitted, the search begins at the start of the string.If
countis omitted, its value defaults to -1, which means that all instances of the substring afterstartare replaced.vbBinaryCompareis ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access