Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

Problem with simple VbYesNo case statement

The following statement is not working... It's just closing out the application when the user clicks yes. I can't see where the problem would be as this is pretty straight forward!
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
 
 
        Select Case MsgBox("Would you like to minimize?", vbYesNo)
            Case vbYes
                Me.WindowState = FormWindowState.Minimized
                Me.Visible = False
                nfi.Visible = True
            Case vbNo
 
                Me.Close()
        End Select
 
 
 
        
        
 
    End Sub

Open in new window

0
c9k9h
Asked:
c9k9h
1 Solution
 
Daniel ReynoldsSoftware Applications Developer / IntegratorCommented:
put a break on the select case statement and walk it thru.

Check the values of the response to the msgbox.

That should help you figure this out.
0
 
MrBookinsCommented:
See below.  At the end of the call to FormClosing the program is normally terminated.  To stop this action set e.Cancel to true.


Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing


Select Case MsgBox("Would you like to minimize?", vbYesNo)
            Case vbYes
                Me.WindowState = FormWindowState.Minimized
                Me.Visible = False
                e.Cancel = True

            Case vbNo

                Me.Close()
        End Select

End Sub
0
 
c9k9hAuthor Commented:
you got it!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now