troubleshooting Question

close application problem

Avatar of brillox
brilloxFlag for United Kingdom of Great Britain and Northern Ireland asked on
Visual Basic.NET
6 Comments3 Solutions211 ViewsLast Modified:
I have a windows application with:

a class called CloseAppl.vb

a form called FormWelcome which is the startup form

the closeAppl.vb cpde is :

Public Class CloseAppl
    Sub CloseNow()

        Dim MainForm As New FormWelcome
        Dim Close As MsgBoxResult
        Close = MsgBox("Did you saved everything before closing this application? If so click on YES", MsgBoxStyle.YesNoCancel, "Exiting....")

        If (Close = vbYes) Then

            MainForm.Close()

        Else

            MsgBox("just click OK and then open FILE and click on 'SAVE'", MsgBoxStyle.Information, "How to save")

        End If

    End Sub
End Class

in the WelcomeForm I have a mainmenu with a subitem Exit application where I try to call teh closeappl class like this:

 Private Sub MenuFileSubCloseappl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuFileSubCloseappl.Click
        Dim CloseObj As New CloseAppl
        CloseObj.CloseNow()
    End Sub

When i click on the menuItem, I do not get any errors, but the application does not close.

If I change the way to do this and in the menu item i type simply me.close() then it works, but then when I will have another form I will need to add a new line of code to create an istance of the welcomeform and close it, instead, using the class, I can just copy na dpaste to all the other forms.

How I have to use that class ?/ what I am doing wrong in use it ?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 3 Answers and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros