Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"VBA." prefix, for example VBA.Randomize vs Randomize, what's the difference?

Tags:

excel

vba

I've just checked some GitHub code and it was full of statements preceded by "VBA.", which work just fine without it.

What's the reason behind adding "VBA."?

like image 787
Ryszard Jędraszyk Avatar asked Dec 11 '22 06:12

Ryszard Jędraszyk


1 Answers

VBA is a reference library which tells the compiler to specifically use the VBA-specific implementation of the method or function which follows.

The reason for this is because there might be other referenced libraries which might have priority by default, and the coder does not know what references you might have or in which order they are.

If you had some other implementation of Randomize and it was higher-up in the order of references, the compiler would expect the parameters to match that particular implementation's format and also use that particular bit of code.

Placing VBA. in front of VBA keywords merely ensures that the version that will be used is the one that the author intended and not some other version.

like image 127
Bill Hileman Avatar answered May 10 '23 08:05

Bill Hileman