Skip to Content
VB.NET Language in a Nutshell, Second Edition
book

VB.NET Language in a Nutshell, Second Edition

by Steven Roman PhD, Ron Petrusha, Paul Lomax
April 2002
Intermediate to advanced
688 pages
19h 51m
English
O'Reilly Media, Inc.
Content preview from VB.NET Language in a Nutshell, Second Edition

Name

Replace Function

Class

Microsoft.VisualBasic.Strings

Syntax

Replace(expression, find, replace [, _
        start[, count[, compare]]])
expression (required; String)

The complete string containing the substring to be replaced

find (required; String)

The substring to be found by the function

replace (required; String)

The new substring to replace find in expression

start (optional; Long)

The character position in expression at which the search for find begins

count (optional; Long)

The number of instances of find to replace

compare (optional; CompareMethod constant)

The method used to compare find with expression; its value can be CompareMethod.Binary (for case-sensitive comparison) or CompareMethod.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

expression = “”

Zero-length string (“”)

find = “”

Copy of expression

replace = “”

Copy of expression with all instances of find removed

start > Len(expression)

Zero-length string (“”)

count = 0

Copy of expression

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 after start are replaced.

  • CompareMethod.BinaryCompare is case sensitive; that is, Replace matches both character and case, whereas CompareMethod.Text is case ...

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.
Start your free trial

You might also like

VB .NET Language in a Nutshell

VB .NET Language in a Nutshell

Steven Roman PhD, Ron Petrusha, Paul Lomax

Publisher Resources

ISBN: 0596003080Supplemental ContentCatalog PageErrata