Re: msgbox syntax question
- From: "Ken Halter" <Ken_Halter@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 15 Jan 2007 14:34:50 -0800
"David" <myself@xxxxxxxxxxx> wrote in message
news:OitqdJPOHHA.4100@xxxxxxxxxxxxxxxxxxxxxxx
Hello all.
I once read, I think in this forum, that the msgbox syntax should be:
msgbox "Your message", vbInformation Or vbYesNo
rather than:
msgbox "Your message", vbInformation + vbYesNo
I can't remember why one uses OR instead of +, can someone please refresh
my
memory?
Thank you
Regards
David Clifford
It's mostly a matter of style, as far as a messagebox goes. vbInformation,
vbYesNo and similar are bitmasks. In most cases, + will work fine, but if
you accidentally add the same flag twice (say, you're passing flags around
to different methods before using them), there can be "issues"... Using Or
to set bitmasks eliminates the possiblity of setting the wrong flags due to
recursion, etc....
'==============
Private Sub Command1_Click()
Dim eBitMask As VbMsgBoxStyle
eBitMask = vbCritical
'Use Plus - Notice the buttons are not set = abort/retry/ignore
eBitMask = eBitMask + vbAbortRetryIgnore
eBitMask = eBitMask + vbAbortRetryIgnore
MsgBox "Test", eBitMask
'Reset mask
eBitMask = vbCritical
'Use Or - Notice the buttons are set = abort/retry/ignore
eBitMask = eBitMask Or vbAbortRetryIgnore
eBitMask = eBitMask Or vbAbortRetryIgnore
MsgBox "Test", eBitMask
End Sub
'==============
--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
In Loving Memory - http://www.vbsight.com/Remembrance.htm
.
- Follow-Ups:
- Re: msgbox syntax question
- From: David
- Re: msgbox syntax question
- References:
- msgbox syntax question
- From: David
- msgbox syntax question
- Prev by Date: msgbox syntax question
- Next by Date: Re: msgbox syntax question
- Previous by thread: msgbox syntax question
- Next by thread: Re: msgbox syntax question
- Index(es):
Loading