473,414 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Or in MsgBox Function

Can someone explain to me what the Or does here?

Dim intReply as Integer = _
MsgBox(strPrompt, MsgBoxStyle.OKCancel Or
MsgBoxStyle.Critical Or MsgBoxStyle.DefaultButton2,
strTitle)

I don't have VB on this cpu... will it display the ok and cancel
buttons and the critical icon ... i still don't understand
DefaultButton, can someone explain that to me as well? Thanks!

Sep 29 '06 #1
6 3287
James wrote:
Can someone explain to me what the Or does here?

Dim intReply as Integer = _
MsgBox(strPrompt, MsgBoxStyle.OKCancel Or
MsgBoxStyle.Critical Or MsgBoxStyle.DefaultButton2,
strTitle)

I don't have VB on this cpu... will it display the ok and cancel
buttons and the critical icon ... i still don't understand
DefaultButton, can someone explain that to me as well? Thanks!
In this context, Or is the bitwise operator. It allows you to combine
bitfield values. In the way it's being used, it's exactly the same as
using + For example

If OKCancel = 1 and Critical = 2 and DefaultButton2 = 4 then

OKCancel Or Critical Or DefaultButton2 = 7
OKCancel + Critical + DefaultButton2 = 7

However Or is the better way to do it, since it keeps you from adding
the same value twice:

OKCancel + Critical + DefaultButton2 + OKCancel = 8
OKCancel Or Critical Or DefaultButton2 Or OKCancel = 7

Do an Internet search for "Bitwise Operators" and you'll probably find
some better explanations.

DefaultButton determines which button on the Message Box has focus when
it is shown. If you pick DefaultButton2 and OKCancel then Cancel would
be in focus an would be the action if the user pressed the space bar or
the Enter key. DefaultButton1 would be the OK button (left to right).

Adam Ruth
Sep 29 '06 #2
so since sgBoxStyle.OKCancel = 1
MsgBoxStyle.Critical = 16
MsgBoxStyle.DefaultButton2 = 256

does that make the bitwise value 273? which is then the value of
intReply? Sorry, I've never delt with this "bitwise" stuff... What is
this used for? Thanks!
Adam Ruth wrote:
James wrote:
Can someone explain to me what the Or does here?

Dim intReply as Integer = _
MsgBox(strPrompt, MsgBoxStyle.OKCancel Or
MsgBoxStyle.Critical Or MsgBoxStyle.DefaultButton2,
strTitle)

I don't have VB on this cpu... will it display the ok and cancel
buttons and the critical icon ... i still don't understand
DefaultButton, can someone explain that to me as well? Thanks!

In this context, Or is the bitwise operator. It allows you to combine
bitfield values. In the way it's being used, it's exactly the same as
using + For example

If OKCancel = 1 and Critical = 2 and DefaultButton2 = 4 then

OKCancel Or Critical Or DefaultButton2 = 7
OKCancel + Critical + DefaultButton2 = 7

However Or is the better way to do it, since it keeps you from adding
the same value twice:

OKCancel + Critical + DefaultButton2 + OKCancel = 8
OKCancel Or Critical Or DefaultButton2 Or OKCancel = 7

Do an Internet search for "Bitwise Operators" and you'll probably find
some better explanations.

DefaultButton determines which button on the Message Box has focus when
it is shown. If you pick DefaultButton2 and OKCancel then Cancel would
be in focus an would be the action if the user pressed the space bar or
the Enter key. DefaultButton1 would be the OK button (left to right).

Adam Ruth
Sep 29 '06 #3
James wrote:
so since sgBoxStyle.OKCancel = 1
MsgBoxStyle.Critical = 16
MsgBoxStyle.DefaultButton2 = 256

does that make the bitwise value 273? which is then the value of
intReply?
Correct, the total of those values is 273. intReply in your example
would actually be set to a value of type MsgBoxResult which would
indicate which button the user pressed. 273 is a number that is passed
to the function which tells the function how to display the message box.
Sorry, I've never delt with this "bitwise" stuff... What is
this used for? Thanks!
No problem, it can be a bit confusing when first encountered. Bitfields
are a way to combine several options into one parameter. Instead of
having separate parameters for each of the options, you combine the set
of options into one number with the Or operator. You'll notice that the
values for each of the options are each double the other one, you have
1, 2, 4, 8, 16, 32, 64, 256, etc. This is because each number
represents a bit in a 32-bit number.

Wikipedia has a good description of how bitwise operations work. Think
of the options parameter as a set of 32 on/off switches and each of the
options (that are joined with Or) as turning on one of the 32 options.

http://en.wikipedia.org/wiki/Bitwise

Adam Ruth
Sep 29 '06 #4
You might check out the Flags attribute for Enumerations. The Flag attribute
makes the or'ing of different enumerations possible such that the receiving
code, i.e.,, msgbox code, can easily decipher what different values of the
Enumeration are passed.

--
Dennis in Houston
"James" wrote:
so since sgBoxStyle.OKCancel = 1
MsgBoxStyle.Critical = 16
MsgBoxStyle.DefaultButton2 = 256

does that make the bitwise value 273? which is then the value of
intReply? Sorry, I've never delt with this "bitwise" stuff... What is
this used for? Thanks!
Adam Ruth wrote:
James wrote:
Can someone explain to me what the Or does here?
>
Dim intReply as Integer = _
MsgBox(strPrompt, MsgBoxStyle.OKCancel Or
MsgBoxStyle.Critical Or MsgBoxStyle.DefaultButton2,
strTitle)
>
I don't have VB on this cpu... will it display the ok and cancel
buttons and the critical icon ... i still don't understand
DefaultButton, can someone explain that to me as well? Thanks!
>
In this context, Or is the bitwise operator. It allows you to combine
bitfield values. In the way it's being used, it's exactly the same as
using + For example

If OKCancel = 1 and Critical = 2 and DefaultButton2 = 4 then

OKCancel Or Critical Or DefaultButton2 = 7
OKCancel + Critical + DefaultButton2 = 7

However Or is the better way to do it, since it keeps you from adding
the same value twice:

OKCancel + Critical + DefaultButton2 + OKCancel = 8
OKCancel Or Critical Or DefaultButton2 Or OKCancel = 7

Do an Internet search for "Bitwise Operators" and you'll probably find
some better explanations.

DefaultButton determines which button on the Message Box has focus when
it is shown. If you pick DefaultButton2 and OKCancel then Cancel would
be in focus an would be the action if the user pressed the space bar or
the Enter key. DefaultButton1 would be the OK button (left to right).

Adam Ruth

Sep 29 '06 #5
Hi Dennis,
Just last week I looked this stuff up "again" and it appears that the Flags
attribute doesn't really affect the way the bitmask works, just how the
..ToString() function treats the value.

Correct me if I'm wrong...
Steve

"Dennis" <De****@discussions.microsoft.comwrote in message
news:E8**********************************@microsof t.com...
You might check out the Flags attribute for Enumerations. The Flag
attribute
makes the or'ing of different enumerations possible such that the
receiving
code, i.e.,, msgbox code, can easily decipher what different values of the
Enumeration are passed.

--
Dennis in Houston
"James" wrote:
>so since sgBoxStyle.OKCancel = 1
MsgBoxStyle.Critical = 16
MsgBoxStyle.DefaultButton2 = 256

does that make the bitwise value 273? which is then the value of
intReply? Sorry, I've never delt with this "bitwise" stuff... What is
this used for? Thanks!
Adam Ruth wrote:
James wrote:
Can someone explain to me what the Or does here?

Dim intReply as Integer = _
MsgBox(strPrompt, MsgBoxStyle.OKCancel Or
MsgBoxStyle.Critical Or MsgBoxStyle.DefaultButton2,
strTitle)

I don't have VB on this cpu... will it display the ok and cancel
buttons and the critical icon ... i still don't understand
DefaultButton, can someone explain that to me as well? Thanks!
In this context, Or is the bitwise operator. It allows you to combine
bitfield values. In the way it's being used, it's exactly the same as
using + For example

If OKCancel = 1 and Critical = 2 and DefaultButton2 = 4 then

OKCancel Or Critical Or DefaultButton2 = 7
OKCancel + Critical + DefaultButton2 = 7

However Or is the better way to do it, since it keeps you from adding
the same value twice:

OKCancel + Critical + DefaultButton2 + OKCancel = 8
OKCancel Or Critical Or DefaultButton2 Or OKCancel = 7

Do an Internet search for "Bitwise Operators" and you'll probably find
some better explanations.

DefaultButton determines which button on the Message Box has focus when
it is shown. If you pick DefaultButton2 and OKCancel then Cancel would
be in focus an would be the action if the user pressed the space bar or
the Enter key. DefaultButton1 would be the OK button (left to right).

Adam Ruth


Oct 2 '06 #6
All I know is what I read in the MSDN under Flags attributes.
--
Dennis in Houston
"Steve Long" wrote:
Hi Dennis,
Just last week I looked this stuff up "again" and it appears that the Flags
attribute doesn't really affect the way the bitmask works, just how the
..ToString() function treats the value.

Correct me if I'm wrong...
Steve

"Dennis" <De****@discussions.microsoft.comwrote in message
news:E8**********************************@microsof t.com...
You might check out the Flags attribute for Enumerations. The Flag
attribute
makes the or'ing of different enumerations possible such that the
receiving
code, i.e.,, msgbox code, can easily decipher what different values of the
Enumeration are passed.

--
Dennis in Houston
"James" wrote:
so since sgBoxStyle.OKCancel = 1
MsgBoxStyle.Critical = 16
MsgBoxStyle.DefaultButton2 = 256

does that make the bitwise value 273? which is then the value of
intReply? Sorry, I've never delt with this "bitwise" stuff... What is
this used for? Thanks!
Adam Ruth wrote:
James wrote:
Can someone explain to me what the Or does here?
>
Dim intReply as Integer = _
MsgBox(strPrompt, MsgBoxStyle.OKCancel Or
MsgBoxStyle.Critical Or MsgBoxStyle.DefaultButton2,
strTitle)
>
I don't have VB on this cpu... will it display the ok and cancel
buttons and the critical icon ... i still don't understand
DefaultButton, can someone explain that to me as well? Thanks!
>

In this context, Or is the bitwise operator. It allows you to combine
bitfield values. In the way it's being used, it's exactly the same as
using + For example

If OKCancel = 1 and Critical = 2 and DefaultButton2 = 4 then

OKCancel Or Critical Or DefaultButton2 = 7
OKCancel + Critical + DefaultButton2 = 7

However Or is the better way to do it, since it keeps you from adding
the same value twice:

OKCancel + Critical + DefaultButton2 + OKCancel = 8
OKCancel Or Critical Or DefaultButton2 Or OKCancel = 7

Do an Internet search for "Bitwise Operators" and you'll probably find
some better explanations.

DefaultButton determines which button on the Message Box has focus when
it is shown. If you pick DefaultButton2 and OKCancel then Cancel would
be in focus an would be the action if the user pressed the space bar or
the Enter key. DefaultButton1 would be the OK button (left to right).

Adam Ruth



Oct 2 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: JT | last post by:
im trying to use the MsgBox function in the following to display an ASP MsgBox containing text retrieved from the db into a recordset <% set rsMessages= myRecordset msg_text =...
3
by: Asif Rahman | last post by:
Hi all! Please improve on the following code to make sure the record gets deleted only when the function returns false. Now I see the msgbox, but the record gets deleted no matter the user...
6
by: Lapchien | last post by:
In this bit of code provided so helpfully by Nath: Private Sub Command118_Click() Dim rs As DAO.Recordset Set db = CurrentDb Set rs = db.openrecordset("IMPORT")
17
by: MLH | last post by:
Can I control what text appears on msgbox function buttons? Sure do like NOT having to build a form to show a msg and solicit a YES/NO response. MsgBox function is a great solution for that. ...
16
by: jhwagner | last post by:
I need to use double data entry with an MS Access database. I have read many arguments and reasons against this on this group but I have to do this. I have seen various tips on how this can be...
14
by: Ant | last post by:
Hello, I'm a newbie to C#. Does it have a Msgbox function like VB6 i.e. MsgBox "Hello World". What is the equivelant function? Does it have one? Thanks for your time on this simple question
1
by: Jay at SCA | last post by:
I've been having the following issue with a windows service I've created in vb.net (.net fw 1.1): Basically, my service monitors a folder for the creation of any new files of a particular type...
6
by: RML | last post by:
Hi all, I have a VB.NET app which contains 1 form. The form starts a thread which does some processing based on what the user is doing on the form. My problem is, the thread can display a MsgBox...
4
by: James | last post by:
What does this mean? 'To specify more than the first argument, you must use the MsgBox function in an expression' I'd love to see an example. Thanks!
1
vdraceil
by: vdraceil | last post by:
Hi everyone, I'm using VB6.I've lately been into working with APIs.I'm working on a program that makes the cursor rotate spirally and as it does so,any window opened will be minimized.The only way...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.