Strings and API Procedures

One of the major differences between C/C++ and VBA is the way string data is handled. In C/C++, a string is treated simply as an array of characters. The name of the string variable is a pointer to the first character in the string—in other words, the memory address where that character is stored. The end of the string is indicated by the null character, which is represented in C/C++ as \0 and in VBA by the constant vbNullChar. This is different from VBA, in which there is no special character used to mark the end of a string; rather, the string length is maintained separately.

This difference in string handling becomes important when using API procedures that return string information to the calling program. The API ...

Get Office® XP Development with VBA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.