Written some cool source code? Upload it to Programmer's Heaven.

VB.NET

Moderators: seancampbell
Number of threads: 3618
Number of posts: 9200

This Forum Only
Post New Thread

Report
Exit button with yes/no options Posted by mihaispr on 13 Nov 2009 at 10:56 AM
Hi everyone and thanks for reading my question!

This is my first topic related on vb.net!


I want to implement an exit button with yes/no option in vb.net.

Here's what I've tried:

Dim intrebare As String
        intrebare = MsgBox("Doriti parasirea aplicatiei?", MsgBoxStyle.YesNo)
        If intrebare = "Yes" Then ' if we press yes it quits vb.net
'here is the problem how to say him if he selects yes to quit from 'visual studio 2008?            

'Me.Close() if I select yes I want that it exits my full 'software , so exits visual studio 2008 is it possible?
           
        Else 
          'ok
            Me.Close()


No syntax error the problem is that even if I select yes or no it returns to me to the initial form. I want to return me on initial form only if I press No Button of MessageBox.


Report
Re: Exit button with yes/no options Posted by seancampbell on 16 Nov 2009 at 7:09 AM
  Dim intrebare As System.Windows.Forms.DialogResult
  intrebare = MsgBox("Doriti parasirea aplicatiei?", MsgBoxStyle.YesNo)
  If intrebare = MsgBoxResult.Yes  Then 
    Me.Close()
  Else 
  End If


Hope this helps!
Report
Re: Exit button with yes/no options Posted by mihaispr on 16 Nov 2009 at 7:42 AM
Thanks! It helps very much!

Best wishes Sean,

Michael
Report
Re: Exit button with yes/no options Posted by seancampbell on 16 Nov 2009 at 12:01 PM
If you want a form to close as apposed to a full application

You can use:

Me.Close() (This closes the form you call this code from, if that form is set as the startup form, it will close the whole application)

Application.End (This closes the whole application, may or may not call your Form_Closing and Form_Closed routines of open forms, so be careful)


---
If you open your application from a Sub Main, and you do not specify a form with Application.Run(), then you have to do a Application.End to end the running process.

Hope this helps!



 
Popular resources and forums for programmers on Programmersheaven.com
Assembly, Basic, C, C#, C++, Delphi, Java, JavaScript, Pascal, Perl, PHP, Python, Ruby, Visual Basic
© Copyright 2009 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Publisher: Lars Hagelin. Read the latest words from the publisher here.
Be the first to sign up for Lars Hagelin’s In-depth Outsourcing Newsletter here.
bootstrapLabs Logo A bootstrapLabs project.