Differences in String Function Operations [Access 2003 VBA Language Reference]
The memory storage formats for text differ between Visual Basic for Applications (VBA) code and Access Basic code. (Access Basic was used in early versions of Microsoft Access.) Text is stored in ANSI format within Access Basic code and in Unicode format in Visual Basic.
The Unicode format is used in Visual Basic to match the format of text within OLE, which is indirectly related to Visual Basic.
For example, the text string "ABC" would be stored in memory as shown below.
|Storage format||Storage pattern||Description|
|Unicode||41 00 42 00 43 00 42 30 44 30 46 30||Each character is stored as 2 bytes.|
|ANSI||41 42 43 82 A0 82 A2 82 A4||ASCII characters are stored as 1 byte; double-byte characters are stored as 2 bytes.|
Because of these differences in internal format, there are string processing functions that operate differently in Access Basic and Visual Basic. The functions that operate differently and their statements are as shown below.
Asc function, Chr function, InputB function, InStrB function, LeftB function, LenB function, RightB function, MidB function, and their corresponding statements.
Also, the ChrB function and AscB function have been added to Visual Basic.
In that these functions and statements both process text in byte units, they are the same in Access Basic and Visual Basic, but because their storage formats for text are different, they operate differently. For example, LenB("A") would be 1 in Access Basic, but 2 in Visual Basic.
Programs created in previous versions of Microsoft Access that use the string processing functions that work in byte units must be changed in Visual Basic to a source code that recognizes Unicode. However, if only string processing functions that process character units, such as the Len function, Left function, and Right function, are used, there is no need to recognize them.
If programs created in a previous version of Microsoft Access are moved to the current version of Microsoft Access, consider issues discussed in the following topics regarding string processing.