WORKING WITH STRINGS

A string is a sequence of characters.

VBA has two types of strings:


Each character in a string takes one byte of memory storage.

In addition, a variable length-string consumes an extra 16 bytes.

Thus to save memory, it is better to use fix-length strings if possible.

When declaring a string variable with a Dim statement, you can specify the maximum length if you know it (it's a fixed-length string) or let VBA handles it dynamically (it's a variable-length string).

For example,

Dim MyString As String * 50     'it is a fix-length string
Dim YourString As String        'it is a variable-length string