Combine multiple args into 1

D

DevlinM

I am curious how Msgbox combines multiple arguments into 1 for
vbMsgBoxStyle(e.g. vbInformation + vbYesNo), as I would like to implement
something like this in one of my own procedures.

Another question I am curious about is how to display argument options when
writing a procedure call. Again, similar to Msgbox, when building the
procedure call, the code window displays a list of options for each argument.

Any help is appreciated.

Devlin
 
A

Allen Browne

Re your first question, use powers of 2 for each element, and then parse
them with a binary AND operation.

There's an example in this Database Issue Checker Utility:
http://allenbrowne.com/AppIssueChecker.html
You check the box for each issue you wish to check.
The form treats each as a power of 2, sums the values, and passes the result
to the function. The function then ANDs with 1, 2, 4, 8, etc, to determine
which bits are turned on.

Re your second question, use an Enum or custom Type. Then declare your
argument as this type, and the options are available.

You can even use the built-in types. For example, if your code has to accept
some type of Access object (form, report whatever), you could declare it
like this:
Public Function MyFunc(WotObject As acObjectType)
 
V

vanderghast

You have to be careful, if you use + instead of AND:


MsgBox "Hello", vbOKCancel + vbOKCancel

as example, does not produce an OK - Cancel, while


MsgBox "Hello",vbOKCancel AND vbOKCancel


does.


Vanderghast, Access MVP
 
S

Stuart McCall

vanderghast said:
You have to be careful, if you use + instead of AND:


MsgBox "Hello", vbOKCancel + vbOKCancel

as example, does not produce an OK - Cancel, while


MsgBox "Hello",vbOKCancel AND vbOKCancel


does.


Vanderghast, Access MVP

Er, shouldn't that be OR?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top