Name
Replace Function
Class
Microsoft.VisualBasic.Strings
Syntax
Replace(expression, find, replace [, _
start[, count[, compare]]]
)
-
expression
Use: Required
Data Type: String
The complete string containing the substring to be replaced
-
find
Use: Required
Data Type: String
The substring to be found by the function
-
replace
Use: Required
Data Type: String
The new substring to replace
find
inexpression
-
start
Use: Optional
Data Type: Long
The character position in
expression
at which the search forfind
begins-
count
Use: Optional
Data Type: Long
The number of instances of
find
to replace-
compare
Use: Optional
Data Type:
CompareMethod
constantThe method used to compare
find
withexpression
; its value can beCompareMethod.Binary
(for case-sensitive comparison) orCompareMethod.Text
(for case-insensitive comparison)
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 (“”) |
|
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, all instances of the substring afterstart
are replaced.CompareMethod.BinaryCompare
is case sensitive; that is,
Get VB .NET Language 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.