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
stringToReplace
instring
.-
start
Use: Optional
Data Subtype: Long
The character position in
string
at which the search forstringToReplace
begins.-
count
Use: Optional
Data Subtype: Long
The number of instances of
stringToReplace
to replace.-
compare
Use: Optional
Data Subtype: Integer
The method that compares
stringToReplace
withstring
; its value can bevbBinaryCompare
orvbTextCompare
.
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
start
is omitted, the search begins at the start of the string.If
count
is omitted, its value defaults to -1, which means that all instances of the substring afterstart
are replaced.vbBinaryCompare
is ...
Get VBScript in a Nutshell 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.