 |
|
|
|
| Author |
Message |
David
Joined: 04 Oct 2007 Posts: 38
|
Posted: Tue Jan 16, 2007 3:08 am Post subject: msgbox syntax question |
|
|
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
Archived from group: microsoft>public>vb>syntax |
|
| Back to top |
|
 |
Ken Halter
Joined: 04 Oct 2007 Posts: 4150
|
Posted: Mon Jan 15, 2007 7:34 pm Post subject: Re: msgbox syntax question |
|
|
"David" wrote in message @TK2MSFTNGP04.phx.gbl...
> 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 |
|
| Back to top |
|
 |
David
Joined: 04 Oct 2007 Posts: 38
|
Posted: Tue Jan 16, 2007 3:42 am Post subject: Re: msgbox syntax question |
|
|
Thank you very much Ken, I do remember it now...also, thanks for the
example.
Regards.
David Clifford
"Ken Halter" wrote in message
news:%23QgxqXPOHHA.3916@TK2MSFTNGP02.phx.gbl...
> "David" wrote in message
> @TK2MSFTNGP04.phx.gbl...
> > 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
>
>
|
|
| Back to top |
|
 |
|
|
| Related Topics: | Question on Loop Syntax... Ok, I'm back. I have another question (probably an easy one, even to non-experts). I was inspired to expand this little program (thanks to all of your help). If I was using the following code to create a game that prompts the user to guess a number from
MSHTML Syntax Question I am using the Web Browser control in an Access 2003 form. I have references set to Microsoft Internet Controls (SHDOCVW.dll) and Microsoft HTML Object Library (MSHTML.tlb). I can click a button with the name "submit1" with the following code: doc.all("
VB syntax question - can you figure out what this does? Hi all, As will be evident from my question, I am fairly new to the VB languages. My question is this: Assume you've got a variable referring to some object, for e.g Dim oServer Set oServer = New CServer What does this syntax really mean (this is a vbscr
Visual Basic 6 and MAPI / CDO 1.21 question - weird syntax hi group, Can anyone explain what they are talking about in this paragraph? Note: When you access an element of the Categories array, whether to read it or write it, you must include an extra set of parentheses to satisfy the Visual Basic compiler's allow
VB 6 MsgBox I am using a msgbox to prompt a user for a yes or no. The prompt pops up right on top of what I want to show the user. How do I change the location of the msgbox? I have seen a few solutions but none of them seemed to allow me to get back a value from |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|