String Functions Offering Utility

With all of this talk about text files, it seems like this would be a good place to mention some useful string functions. Rare is the procedure that reads/writes from a text file that does not use one of the functions listed in Table 15.1.

Table 15.1: Useful String functions function use

Left Returns x characters from the left of a string

Len Returns the length of a string

LTrim Trims any spaces from the left of a string

Table 15.1: Useful String Functions (continued)

Function

use

Mid

Returns x characters from the middle of a string starting with character y

Right

Returns x characters from the right of a string

RTrim

Trims any spaces from the right of a string

Split

Splits a delimited string into an array of individual values

StrConv

Converts a string to the specified format

Trim

Trims any spaces from the left and right of a string

This is not a complete list of string functions; rather, it is a list of the functions I use the most when working with text files. Listing 15.7 provides an example of these functions.

NOTE For further reference, check, out VBA Developer's Handbook, Second Edition by Ken Getz and Mike Gilbert (Sybex, 2001). They have a whole chapter dedicated to working with strings.

0 0

Post a comment