Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. MsgBox brainteaser

MsgBox brainteaser

Scheduled Pinned Locked Moved Visual Basic
questioncsharpcomhelp
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ii_noname_ii
    wrote on last edited by
    #1

    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?

    D S 2 Replies Last reply
    0
    • I ii_noname_ii

      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?

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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 1 Reply Last reply
      0
      • I ii_noname_ii

        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?

        S Offline
        S Offline
        Steven J Jowett
        wrote on last edited by
        #3

        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

        I 1 Reply Last reply
        0
        • S Steven J 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 Jowett

          I Offline
          I Offline
          ii_noname_ii
          wrote on last edited by
          #4

          I get "name MessageBox not declared" :s

          S 1 Reply Last reply
          0
          • D Dave Kreskowiak

            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 Offline
            I Offline
            ii_noname_ii
            wrote on last edited by
            #5

            I get 'MsgBoxResultmbr' is not defined...

            D 1 Reply Last reply
            0
            • I ii_noname_ii

              I get "name MessageBox not declared" :s

              S Offline
              S Offline
              Steven J Jowett
              wrote on last edited by
              #6

              Imports System.Windows.Forms Thank should sort it. Steve Jowett

              I 1 Reply Last reply
              0
              • S Steven J Jowett

                Imports System.Windows.Forms Thank should sort it. Steve Jowett

                I Offline
                I Offline
                ii_noname_ii
                wrote on last edited by
                #7

                Thanx!:-D

                1 Reply Last reply
                0
                • I ii_noname_ii

                  I get 'MsgBoxResultmbr' is not defined...

                  D Offline
                  D Offline
                  Dave Kreskowiak
                  wrote on last edited by
                  #8

                  Put this at the top of your code:

                  Imports Microsoft.VisualBasic

                  Dave Kreskowiak Microsoft MVP - Visual Basic

                  I 1 Reply Last reply
                  0
                  • D Dave Kreskowiak

                    Put this at the top of your code:

                    Imports Microsoft.VisualBasic

                    Dave Kreskowiak Microsoft MVP - Visual Basic

                    I Offline
                    I Offline
                    ii_noname_ii
                    wrote on last edited by
                    #9

                    ty sir :P

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups