just closing the main form

yaniv

Well-known member
Joined
Apr 15, 2002
Messages
162
Location
israel
Well, i think that i understood that i have to create a new object to open form and then i use the object to close the form, but can i close the main form (the start page)?
 
its doesnt work.

this is my code:
(i want the button to open the new form and to close the menu)

Code:
private sub button1_click
dim frm as new form1()
frm.show()
me.close
end sub


and it doest work, the me.close is closing (as i see it) the new form.
 
well, i discovered that when i use the me.close and close the main form i just closing the all program.

what i"m looking for now is a way to close the main form while the second one is open and to reopen it when i close the second.

what i did is to use sub main to create te main form, and i can now hide it, but when i"m in the second form, i cant find the way to recognize the main form.

i just cant give him a name that the second form recognize.

do you idea?
 
You cant public a form in a shared sub (which is the main sub).

application.exit is closing the entire program.
 
You need to modify your sub main (or create one if you dont already have one) and use Application.Run() (note no parameters) to start an application-wide message loop that isnt dependant on any one form. The default behaviour is to have your message loop based on a main form, and therefore it shuts down when that form does.

This will solve your problem, but introduce a new one - when you have a message loop that doesnt depend on one form, you must then manually call Application.Exit() when you really do want your application to close.
 
well i changed the sub main, but i do have to start with some form, no?

so i used this code:
Code:
    Public Shared Sub main()
        Application.Run()

        Dim frm As New Form1()
        frm.show()


    End Sub

but nothing happen!!

i do think i miss something, it supposed to be simple, no?
 
Back
Top