Remove Duplicate Spaces or the Duplicate Character of Your Choice from a String

Category:
String Manipulation
Type:
Snippets
Difficulty:
Intermediate
Author:
Brian Gillham

Version Compatibility: Visual Basic 6, Visual Basic.NET

More information:
VB Supplies a function to Trim Spaces from the Beginning or End of a string. The one thing they forgot to include was to strip Extra Spaces from within the string. That is why I wrote TrimALL (A HREF = 'http://www.freevbcode.com/ShowCode.Asp?ID=2999'>http://www.freevbcode.com/ShowCode.Asp?ID=2999. This function is a variation on the original, it not only strips ALL duplicate spaces from a string but it can also remove ANY duplicate characters (including vbCrLf etc.) from a string using the Character of your choice.

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: