WORKING WITH STRINGS
A string is a sequence of characters.
VBA has two types of strings:
-
Fixed-length strings are declared with a specified maximum number of characters.
The maximum declared length is about 65526.
-
Variable-length strings theoretically can hold as many as two billion characters.
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