Z
zionsaal
what the difference between dim and const?
what the difference between dim and const?
Dim reserves space for a variable which you can change; const
defines a constant which you can use but NOT change.
David said:And at compile time, the constant value is hardcoded into all the
places where it's been used.
Are you sure? I thought I'd seen some decompiled
VBA indicating that is not the case?
The way it could be done is the way it often has
been done, the way it is done in C: constants
implemented as initialised variables.
Which brings me back to the original question:
Decoded VBA always shows implicit variables and the
implicit close statements for objects, so I can't
remember exactly what I've seen: decoded VBA always
shows implicit variables, are some of those implicit
variables the const values?
The way it could be done is the way it often has
been done, the way it is done in C: constants
implemented as initialised variables.
But it *isn't* by VBA.
Check it out yourself -- create an MDE and then browse the binary
file and you'll see the constants hardwired into every time they are
called.
[irrelevant discussion of compiling in a completely different
languaged deleted]
Which brings me back to the original question:
Decoded VBA always shows implicit variables and the
implicit close statements for objects, so I can't
remember exactly what I've seen: decoded VBA always
shows implicit variables, are some of those implicit
variables the const values?
What is "decoded VBA?" Are you talking decompiled?
Well, I said *compiled* VBA, which means, well, the actually
compiled p-code. In that p-code, you'll see all literal strings used
anywhere in the code, whether declared as constants or not, and each
use of a constant in the canonical code will be replaced with the
literal value of the constant.
You can check it out and see for yourself.
But references to the compilation of completely different languages
that have zilch to do with VBA's code compilation are not helpful.