Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
How to: Remove Parts of a String (Visual Basic)

How to: Remove Parts of a String (Visual Basic) 

The following code example removes all occurrences of one string from another string.

Example

This example uses the Replace function to replace each occurrence of the substring with an empty string. The result is a new string with the substrings removed.

The example assigns the return value of the Replace function to the string variable withoutParts. The original string, stored in withParts, is not changed.

Dim withParts As String = "Books and Chapters and Pages"
Dim withoutParts As String = Replace(withParts, "and ", "")

Compiling the Code

Replace "Books and Chapters and Pages" with the string you want to manipulate.

See Also

Community Additions

ADD
Show:
© 2015 Microsoft