Replace$ Function
Syntax
Replace[$](S$, Pat$, Rep$, [Index], [Count])
Group
Description
Replaces Pat$ with Rep$ in S$.
Parameters
| Parameters | Description |
|---|---|
| S$ | The string value is searched. Replacements are made in the string returned by Replace. |
| Pat$ | The string value is the pattern to look for. |
| Rep$ | The string value is the replacement. |
| Index | The starting index in S$. Replace(S,Pat,Rep,N) is equivalent to Replace(Mid(S,N),Pat,Rep). If this is omitted, use 1. |
| Count | The maximum number of replacements that are done. If this is omitted, use -1 (replaces all occurrences). |
Example
Sub Main Debug.Print Replace$("abcabc","b","B") '"aBcaBc" Debug.Print Replace$("abcabc","b","B",,1) '"aBcabc" Debug.Print Replace$("abcabc","b","B",3) '"caBc" Debug.Print Replace$("abcabc","b","B",9) '"" End Sub
See also