Hello
I'm sure that anyone with VB.NET would be familiar with the msgbox parameter syntax
Dim msg As Strin
Dim title As Strin
Dim style As MsgBoxStyl
Dim response As MsgBoxResul
msg = "Do you want to continue?" ' Define message
style = MsgBoxStyle.DefaultButton2 Or
MsgBoxStyle.Critical Or MsgBoxStyle.YesN
title = "MsgBox Demonstration" ' Define title
' Display message
response = MsgBox(msg, style, title
So I pass in something like
style = MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Critical Or MsgBoxStyle.YesN
And it knows that I want a message box with a Yes and a No button, an exclamation point icon, and make the No button the default
DefaultButton2 = 256, critical = 16, and YesNo =
When I do the style = MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Critical Or MsgBoxStyle.YesNo, I see style = 276
The "+" operator will work as well, but the Intellisense doesn't work when I do this
I can't find this functionality of the "Or" operator documented anywhere
What I'm trying to do is something like
Begin Pseudo code ===============
Private Enum MyEnu
MyVal0=
MyVal1=
MyVal2=
End Enu
Dim MyVar as MyEnu
If MyCriteria1= True The
MyVar = MyVal
End I
If MyCriteria2 True The
MyVar = MyVar Or MyVal
End I
If MyVar Was assigned to MyVal0 The
'Do Somethin
If MyVar Was Assigned to MyVal1 The
'Do Somethin
End Pseudo code ===============
I can change MyEnum such that MyVal0 = 4, MyVal1 = 16, etc. and then do a
If MyVar Mod MyVal1 = 0 the
MyVar -= MyVal
If MyVar Mod MyVal0 = 0 the
'Do somethin
'Go to the next smallest MyVa
Any idea how the messagebox function does it
Thanks
Eric 4 2277
Hi, it's all with bits...
Your flags should start from 1, then double themselves...
<Flags()> _
Public Enum MyEnum
Val1 = 1
Val2 = 2
Val3 = 4
Val4 = 8
End Enum
Then, you can "Or" them into your variable:
'==
Dim MyVar As MyEnum = MyEnum.Val1 Or MyEnum.Val3
'==
And to test for their presence, you need to "And" them...
'==
If (MyVar And MyEnum.Val1) = MyEnum.Val1 Then
' Val1 is in there
End If
If (MyVar And MyEnum.Val2) = MyEnum.Val2 Then
' Val2 is in there
End If
If (MyVar And MyEnum.Val3) = MyEnum.Val3 Then
' Val3 is in there
End If
If (MyVar And MyEnum.Val4) = MyEnum.Val4 Then
' Val4 is in there
End If
'==
--
HTH,
-- Tom Spink, Über Geek
Woe be the day VBC.EXE says, "OrElse what?"
Please respond to the newsgroup,
so all can benefit
"Eric Goforth" <an*******@discussions.microsoft.com> wrote in message
news:6B**********************************@microsof t.com... Hello,
I'm sure that anyone with VB.NET would be familiar with the msgbox
parameter syntax: Dim msg As String Dim title As String Dim style As MsgBoxStyle Dim response As MsgBoxResult msg = "Do you want to continue?" ' Define message. style = MsgBoxStyle.DefaultButton2 Or _ MsgBoxStyle.Critical Or MsgBoxStyle.YesNo title = "MsgBox Demonstration" ' Define title. ' Display message. response = MsgBox(msg, style, title)
So I pass in something like
style = MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Critical Or
MsgBoxStyle.YesNo And it knows that I want a message box with a Yes and a No button, an
exclamation point icon, and make the No button the default. DefaultButton2 = 256, critical = 16, and YesNo = 4
When I do the style = MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Critical
Or MsgBoxStyle.YesNo, I see style = 276. The "+" operator will work as well, but the Intellisense doesn't work when
I do this. I can't find this functionality of the "Or" operator documented anywhere.
What I'm trying to do is something like:
Begin Pseudo code ================
Private Enum MyEnum MyVal0=0 MyVal1=1 MyVal2=2 End Enum
Dim MyVar as MyEnum
If MyCriteria1= True Then MyVar = MyVal0 End If
If MyCriteria2 True Then MyVar = MyVar Or MyVal1 End If
If MyVar Was assigned to MyVal0 Then 'Do Something
If MyVar Was Assigned to MyVal1 Then 'Do Something
End Pseudo code ================
I can change MyEnum such that MyVal0 = 4, MyVal1 = 16, etc. and then do a If MyVar Mod MyVal1 = 0 then MyVar -= MyVal1
If MyVar Mod MyVal0 = 0 then 'Do something
'Go to the next smallest MyVal
Any idea how the messagebox function does it?
Thanks, Eric
* =?Utf-8?B?RXJpYyBHb2ZvcnRo?= <an*******@discussions.microsoft.com> scripsit: I'm sure that anyone with VB.NET would be familiar with the msgbox parameter syntax:
Dim msg As String Dim title As String Dim style As MsgBoxStyle Dim response As MsgBoxResult msg = "Do you want to continue?" ' Define message. style = MsgBoxStyle.DefaultButton2 Or _ MsgBoxStyle.Critical Or MsgBoxStyle.YesNo title = "MsgBox Demonstration" ' Define title. ' Display message. response = MsgBox(msg, style, title)
So I pass in something like
style = MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Critical Or MsgBoxStyle.YesNo
And it knows that I want a message box with a Yes and a No button, an exclamation point icon, and make the No button the default.
DefaultButton2 = 256, critical = 16, and YesNo = 4
When I do the style = MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Critical Or MsgBoxStyle.YesNo, I see style = 276.
The "+" operator will work as well, but the Intellisense doesn't work when I do this.
I can't find this functionality of the "Or" operator documented anywhere.
What I'm trying to do is something like:
Begin Pseudo code ================
Private Enum MyEnum MyVal0=0 MyVal1=1 MyVal2=2 End Enum
Dim MyVar as MyEnum
If MyCriteria1= True Then MyVar = MyVal0 End If
If MyCriteria2 True Then MyVar = MyVar Or MyVal1 End If
If MyVar Was assigned to MyVal0 Then 'Do Something
If MyVar Was Assigned to MyVal1 Then 'Do Something
End Pseudo code ================
\\\
<Flags()> _
Public Enum MyMessageBoxStyles
CancelButton = 1
Exclamation = 2
HelpButton = 4
SystemModal = 8
End Enum
Public Function MyMessageBox(ByVal Styles As MyMessageBoxStyles) As String
If (Styles And MyMessageBoxStyles.CancelButton) <> 0 Then
AddCancelButton(...)
End If
If (Styles And MyMessageBoxStyles.Exclamation) <> 0 Then
AddExclamationMark(...)
End If
Eric,
In addition to the others comments, I find the shift operator in VB.NET 2003
useful to define a Flags enum:
<Flags()> _
Public Enum MyEnum
Val1 = 1 << 0
Val2 = 1 << 1
Val3 = 1 << 2
Val4 = 1 << 3
End Enum
As it "tells" me Val1 is the 0 bit, Val2 is the 1 bit, Val3 is the 2 bit,
Val4 is the 3 bit...
Hope this helps
Jay
"Eric Goforth" <an*******@discussions.microsoft.com> wrote in message
news:6B**********************************@microsof t.com... Hello,
I'm sure that anyone with VB.NET would be familiar with the msgbox
parameter syntax: Dim msg As String Dim title As String Dim style As MsgBoxStyle Dim response As MsgBoxResult msg = "Do you want to continue?" ' Define message. style = MsgBoxStyle.DefaultButton2 Or _ MsgBoxStyle.Critical Or MsgBoxStyle.YesNo title = "MsgBox Demonstration" ' Define title. ' Display message. response = MsgBox(msg, style, title)
So I pass in something like
style = MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Critical Or
MsgBoxStyle.YesNo And it knows that I want a message box with a Yes and a No button, an
exclamation point icon, and make the No button the default. DefaultButton2 = 256, critical = 16, and YesNo = 4
When I do the style = MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Critical
Or MsgBoxStyle.YesNo, I see style = 276. The "+" operator will work as well, but the Intellisense doesn't work when
I do this. I can't find this functionality of the "Or" operator documented anywhere.
What I'm trying to do is something like:
Begin Pseudo code ================
Private Enum MyEnum MyVal0=0 MyVal1=1 MyVal2=2 End Enum
Dim MyVar as MyEnum
If MyCriteria1= True Then MyVar = MyVal0 End If
If MyCriteria2 True Then MyVar = MyVar Or MyVal1 End If
If MyVar Was assigned to MyVal0 Then 'Do Something
If MyVar Was Assigned to MyVal1 Then 'Do Something
End Pseudo code ================
I can change MyEnum such that MyVal0 = 4, MyVal1 = 16, etc. and then do a If MyVar Mod MyVal1 = 0 then MyVar -= MyVal1
If MyVar Mod MyVal0 = 0 then 'Do something
'Go to the next smallest MyVal
Any idea how the messagebox function does it?
Thanks, Eric
Nice! :-)
--
HTH,
-- Tom Spink, Über Geek
Woe be the day VBC.EXE says, "OrElse what?"
Please respond to the newsgroup,
so all can benefit
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:eI*************@tk2msftngp13.phx.gbl... Eric, In addition to the others comments, I find the shift operator in VB.NET
2003 useful to define a Flags enum:
<Flags()> _ Public Enum MyEnum Val1 = 1 << 0 Val2 = 1 << 1 Val3 = 1 << 2 Val4 = 1 << 3 End Enum
As it "tells" me Val1 is the 0 bit, Val2 is the 1 bit, Val3 is the 2 bit, Val4 is the 3 bit...
Hope this helps Jay
"Eric Goforth" <an*******@discussions.microsoft.com> wrote in message news:6B**********************************@microsof t.com... Hello,
I'm sure that anyone with VB.NET would be familiar with the msgbox parameter syntax: Dim msg As String Dim title As String Dim style As MsgBoxStyle Dim response As MsgBoxResult msg = "Do you want to continue?" ' Define message. style = MsgBoxStyle.DefaultButton2 Or _ MsgBoxStyle.Critical Or MsgBoxStyle.YesNo title = "MsgBox Demonstration" ' Define title. ' Display message. response = MsgBox(msg, style, title)
So I pass in something like
style = MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Critical Or
MsgBoxStyle.YesNo And it knows that I want a message box with a Yes and a No button, an
exclamation point icon, and make the No button the default. DefaultButton2 = 256, critical = 16, and YesNo = 4
When I do the style = MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Critical
Or MsgBoxStyle.YesNo, I see style = 276. The "+" operator will work as well, but the Intellisense doesn't work
when I do this. I can't find this functionality of the "Or" operator documented
anywhere. What I'm trying to do is something like:
Begin Pseudo code ================
Private Enum MyEnum MyVal0=0 MyVal1=1 MyVal2=2 End Enum
Dim MyVar as MyEnum
If MyCriteria1= True Then MyVar = MyVal0 End If
If MyCriteria2 True Then MyVar = MyVar Or MyVal1 End If
If MyVar Was assigned to MyVal0 Then 'Do Something
If MyVar Was Assigned to MyVal1 Then 'Do Something
End Pseudo code ================
I can change MyEnum such that MyVal0 = 4, MyVal1 = 16, etc. and then do
a If MyVar Mod MyVal1 = 0 then MyVar -= MyVal1
If MyVar Mod MyVal0 = 0 then 'Do something
'Go to the next smallest MyVal
Any idea how the messagebox function does it?
Thanks, Eric
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: ded' |
last post by:
Hello !
I've read in a magazine "reference parameter in operator= must be const,
because in C++, temporary objects are const" and then my operator would
not work with temporary objets.
But,...
|
by: John Wright |
last post by:
How can I close a msgbox programtically. I have a process that can run
24/7. If an operator is not at the station, I want to close the msgbox that
appears. How can I do this?
John
|
by: lrobo01 |
last post by:
I'm having a problem with Crystal report.net with ASP.NET.
The problem occurs when exporting the report. The report
uses a discrete parameter with multiple values. When the
report is loaded into...
|
by: lrobo01 |
last post by:
I'm having a problem with Crystal report.net with ASP.NET.
The problem occurs when exporting the report. The report
uses a discrete parameter with multiple values. When the
report is loaded into...
|
by: James |
last post by:
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...
|
by: =?Utf-8?B?UHVjY2E=?= |
last post by:
The function that I'm trying to call through DLLImport has a parameter that
has a C code's vector's Itrator to a structure. I Have marshalled the
structure in C# but how do I do the C type...
|
by: lee123 |
last post by:
I have a form I have been working on and now I am almost done with it but there is just one thing I need to finish it that I can figure out. Well I have a questionnaire form with 50 questions and I...
|
by: perkykoala |
last post by:
I apologize in advance for being REALLY detailed/verbose. It's the result of staring/tweaking code for too long.
Using VB 2005:
I need to design a multiple choice test (unfortunately, I can't...
|
by: win |
last post by:
I'm using ASP.Net 2.0
MsgBox("Are you sure to delete?", MsgBoxStyle.Question +
MsgBoxStyle.OkCancel, Page.Title.ToString)
The message box sometimes does not pop up on the top of the screen....
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |