This function replaces a specified substring with another specified substring a specified number of times.
Replace(expression, find, replacewith, [start], [count], [compare])
Constant |
Value |
Description |
vbBinaryCompare | 0 | Perform a binary comparison. |
vbTextCompare | 1 | Perform a textual comparison. |
vbDatabaseCompare | 2 | Not supported |
The following table shows the return values for the Replace function.
If |
Replace returns |
expression is zero-length | A zero-length string ("") |
expression is Null | An error |
find is zero-length | A copy of expression |
replacewith is zero-length | A copy of expression with all occurrences of find removed |
start > Len(expression) | A zero-length string |
count is 0 | A copy of expression |
The return value of Replace is a string, with substitutions made, that begins at the position specified by start and concludes at the end of the expression string. It is not a copy of the original string from start to finish.