Function String Words Class

StringWidth

Determine the width of a string in characters, assuming that backspace characters have a width of -1 (because they move the print positions back one space) and all but the carriage control characters have a width of 1.

Signature (Visual Basic / VBA)

Public Function StringWidth( _
    ByVal vValue As Variant _
    ) As Variant

Code Example

    StringWidth("This is a test.") = 15
    StringWidth("Sm" + Chr$(8) + "ample") = 6

Parameters

Parameter Description
vValue The string whose printed width is to be determined. Function returns Null if vValue is Null or cannot be fixed up to a String.

Notes & Version History

Note The MetaPhone function is better at distinguishing words which are spelled differently but may sound alike.
Note Function uses the built-in character classification routines to determine which characters represent carriage control codes.