Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
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)?
Posted

it's doesn't work.

 

this is my code:

(i want the button to open the new form and to close the menu)

 

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

 

 

and it does't work, the me.close is closing (as i see it) the new form.

Posted

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 can't find the way to recognize the main form.

 

i just can't give him a name that the second form recognize.

 

do you idea?

Guest mutant
Posted
Did you dim the form as Public in your sub main?
  • *Gurus*
Posted

You need to modify your sub main (or create one if you don't already have one) and use Application.Run() (note no parameters) to start an application-wide message loop that isn't 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 doesn't depend on one form, you must then manually call Application.Exit() when you really do want your application to close.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

well i changed the sub main, but i do have to start with some form, no?

 

so i used this 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?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...