Re: Inputbox Question



Bob Butler wrote:
> > Also, any place where "" *IS* needed, you should use the constant
> > "vbNullString" instead.
>
> No, you shouldn't. vbNullString is documented as being available for use in
> calling external API procedures that need to differentiate between "" and a
> null pointer; it is not documented as being a substitute for "". In the VB
> environment the implementation of vbNullString ends up being effectively
> identical to "" but they are not the same thing and you should not confuse
> the two. (It mattered more when there was a chance that there'd be a VB7
> since you'd be running the risk of code not working if the implementation
> changed so it's really a moot point now.)

I wasn't confusing the two ("" and vbNullString), but as you've pointed
out, as implemented in VB they are *effectively* the same.

When you use the literal value "", you are introducing bloat into your
program. Each BSTR you define consumes an additional 4 bytes of memory.
Using a *constant* in its place reduces this bloat.

So, YES, you *should* use a constant instead of having hundreds of ""'s
throughout your code. And if you are scared of using vbNullString, then
simply define your own constant and use it instead of adding literal
zero-length strings throughout your code. The idea is to use a
constant, instead of a literal value, in order to reduce unnecessary
bloat in your program.

.


Loading