Remove Trailing and Extra Spaces/Non-Printing Characters from a String

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

Version Compatibility: Visual Basic 6

More information:
This is an efficient way of getting rid of unwanted spaces (leading, trailing, and extra spaces between words) in your strings. I have modified the code (updated 3/31/03) to remove unwanted / non-printable characters as well.

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

Declarations:

Code: