Combine multiple args into 1

  • Thread starter Thread starter DevlinM
  • Start date Start date
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
 
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)
 
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
 
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?
 
Back
Top