# [AccessD] VBA Function with parameters

Stuart McLachlan stuart at lexacorp.com.pg
Sun Nov 7 16:50:17 CST 2021

```Not just in the VBA world. :)

You find  then in C, Java, Javascript,  many BASIC dialects for example.
( but they didn't make it into PHP until v8.1)

I use them all the time to create meaningful equates

Boolean "bitwise" comparisons and bitwise manipulation are very useful tools to a
programmer.

"I am posting this thinking it might be helpful for someone else wondering
what is behind the "addition" of enum parameters set up as powers of two.
"

"AND" is true if, and only if the same bit is set in both values so

If cm And 4  is true if the "4 bit" is set.
That is why we use values that have a single bit set in binary

1 = 0001
2 = 0010
4 = 0100
8 = 1000
(16 = 0001 0000, 32 = 0010 0000 ...)

If cm = 7 (0111) then
cm AND 1 is true
cm AND 2 is true
cm AND 4 is true

If cm = 6 ("0101) then
cm AND 1 is true
cm AND 2 is false
cm as 4 is true

On 8 Nov 2021 at 8:05, Borge Hansen wrote:

> Thanks Paul and Stewart,
> Enum is great...
> Stewart´s example got me googling ...
>
> Link here explains what Enum is in the VBA world:
>  ...
> So what is behind an expression like this?
> If cm And x ??
>   Bitwise enumeration ...
>

```