MsgBox brainteaser
-
Hi, In my vb.net appliction, I use MsgBoxs... example: Dim msg = MsgBox("Are you sure you want to delete this learning?", 4100, "confirm delete") If msg = 6 Then (...) (4100 is a yes no msgbox, always on top, useful MsgBox helper: http://www.autohotkey.com/docs/commands/MsgBox.htm[^]) Now the problem: This msgbox is a deletion confirm from a large datagrid... But while the MsgBox is on top, u can still click on the application under, which creates errors, for example, if u click the "edit" button, then click yes on msgbox... How can i block application while msgbox is not clicked?
-
Hi, In my vb.net appliction, I use MsgBoxs... example: Dim msg = MsgBox("Are you sure you want to delete this learning?", 4100, "confirm delete") If msg = 6 Then (...) (4100 is a yes no msgbox, always on top, useful MsgBox helper: http://www.autohotkey.com/docs/commands/MsgBox.htm[^]) Now the problem: This msgbox is a deletion confirm from a large datagrid... But while the MsgBox is on top, u can still click on the application under, which creates errors, for example, if u click the "edit" button, then click yes on msgbox... How can i block application while msgbox is not clicked?
I have to question your us of the bit values when it's much easier to read an maintain the actual Enums used by thh MsgBox. Also, you're using the SystemModal attribute, which halts access to ALL applications in the system. Not very friendly, is it? Use ApplicationModal instead and you'll get the result you want:
Dim mbr As MsgBoxResult
mbr = MsgBox("Are you sure?", MsgBoxStyle.YesNo Or MsgBoxStyle.ApplicationModal, "Confirm Delete")
If mbr = MsgBoxResult.Yes Then
...Dave Kreskowiak Microsoft MVP - Visual Basic
-
Hi, In my vb.net appliction, I use MsgBoxs... example: Dim msg = MsgBox("Are you sure you want to delete this learning?", 4100, "confirm delete") If msg = 6 Then (...) (4100 is a yes no msgbox, always on top, useful MsgBox helper: http://www.autohotkey.com/docs/commands/MsgBox.htm[^]) Now the problem: This msgbox is a deletion confirm from a large datagrid... But while the MsgBox is on top, u can still click on the application under, which creates errors, for example, if u click the "edit" button, then click yes on msgbox... How can i block application while msgbox is not clicked?
Why are you using MsgBox and not the MessageBox?
Select Case MessageBox.Show("Are you sure you want to delete this learning?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) Case Windows.Forms.DialogResult.Yes 'Yes code here Case Windows.Forms.DialogResult.No 'No code here End Select
Easier to read, and uses the .NET messagebox rather than the VB6- legacy MsgBox Steve Jowett -
Why are you using MsgBox and not the MessageBox?
Select Case MessageBox.Show("Are you sure you want to delete this learning?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) Case Windows.Forms.DialogResult.Yes 'Yes code here Case Windows.Forms.DialogResult.No 'No code here End Select
Easier to read, and uses the .NET messagebox rather than the VB6- legacy MsgBox Steve JowettI get "name MessageBox not declared" :s
-
I have to question your us of the bit values when it's much easier to read an maintain the actual Enums used by thh MsgBox. Also, you're using the SystemModal attribute, which halts access to ALL applications in the system. Not very friendly, is it? Use ApplicationModal instead and you'll get the result you want:
Dim mbr As MsgBoxResult
mbr = MsgBox("Are you sure?", MsgBoxStyle.YesNo Or MsgBoxStyle.ApplicationModal, "Confirm Delete")
If mbr = MsgBoxResult.Yes Then
...Dave Kreskowiak Microsoft MVP - Visual Basic
I get 'MsgBoxResultmbr' is not defined...
-
I get "name MessageBox not declared" :s
Imports System.Windows.Forms
Thank should sort it. Steve Jowett -
Imports System.Windows.Forms
Thank should sort it. Steve JowettThanx!:-D
-
I get 'MsgBoxResultmbr' is not defined...
Put this at the top of your code:
Imports Microsoft.VisualBasic
Dave Kreskowiak Microsoft MVP - Visual Basic
-
Put this at the top of your code:
Imports Microsoft.VisualBasic
Dave Kreskowiak Microsoft MVP - Visual Basic
ty sir :P