bottom
Great WordTips!
         
Your e-mail address is safe!
Close Note

Tips.Net > WordTips Home > Macros > Creating Macros > Dissecting a String

Dissecting a String

Summary: When writing macros, you often need to slice and dice strings so you can determine their different parts. VBA provides three primary functions you use for this purpose, as described in this tip. (This tip works with Microsoft Word 97, Word 2000, Word 2002, and Word 2003.)

If you have used BASIC before, you will be right at home with the string functions provided by VBA. The following table details the most common string functions and what they return.

Function Comments
Left(Source, Count) Returns the left Count characters of Source.
Mid(Source, Start [, Count]) Returns the portion of Source beginning with the Start character. If Count is supplied, then the result is limited to that many characters.
Right(Source, Count) Returns the right Count characters of Source.

When working with these string functions, remember that the Source variable must be declared as a string in order for the functions to work properly.

Tip #1073 applies to Microsoft Word versions: 97 | 2000 | 2002 | 2003


Save Time! You can have this tip (and several hundred just like it) in the WordTips annual archives. Imagine having over 400 tips available at your fingertips, in each annual volume.

Helpful Links

Ask a Word Question
Make a Comment

Tips.Net Home
Vital News Home

WordTips FAQ
WordTips Premium

Learn Access Now

Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips

Advertise on the
WordTips Site

 

Great Info!

Get tips like this every week in WordTips, a free productivity newsletter. Enter your e-mail address and click "Subscribe."
     
(Your e-mail address will never be shared with anyone, ever.)