VBA Tip: Trim Text Input

Written by Rod Wing.


The Trim$ function removes any leading or trailing space characters from a string.

' returns "abc"
strValue = Trim$ ("     abc     ")

Use the Trim$ function on all user entered text input. It is very easy for the user to enter a hidden space at the beginning or ending of a text field on a user form. Trimming all text inputs can eliminate a lot of frustrations in tracking down why your macro isn’t working properly.

Last Month’s Tips:

3d civil content for microstation visualization   Screenshot   1           exterminator

MicroStation: 3D Civil             InRoads: GEOPAK                   AutoCAD Civil 3D 2014:          VBA: Debug
for MicroStation Vis…            Corridor Modeling Cr…          Adding Extended Data to…   
Don’t want to miss out on other great information? Subscribe to this blog or our monthly eNewsletter now!
Learn More ◊ Contact us today ◊ Newsletter ◊
EnvisionCAD Group EnvisionCAD YouTube Channel   



Since 1996, EnvisionCAD has been a nationally recognized leader in the configuration, customization, implementation, training & support for CAD software solutions. Our individualized approach has benefited private engineering firms and government agencies alike. Basic or advanced, we can help you get the most from your CAD technology.


Leave a Reply

Your email address will not be published. Required fields are marked *