Æion Posted October 25, 2003 Posted October 25, 2003 I'm pretty new to MSVS and i've been working my off the past week to learn it but aside from most arrays and do while statements that i don't understand yet i've got a problem that i haven't been able to solve since the beginning. I've got a project with 2 forms how do i control which one is the initial form? and how do i close that form after i open the other one? I can hide it, but thats not good enough If i use Me.close() it takes all other forms down with it I'm using a module if that can be of any use to denoting the "main form" or closing the main form any input would be great for a humble beginner Quote
atesh Posted October 25, 2003 Posted October 25, 2003 To set which form is the initial form, goto Project, Properties, and you'll see a drop down box called Startup Object where you select this. Quote To err is human, to really foul things up requires a computer.
Æion Posted October 25, 2003 Author Posted October 25, 2003 Thanks, thats exactly what i was looking for.... took me so long to find. what a shame... thanks Quote
Æion Posted October 25, 2003 Author Posted October 25, 2003 There is still a problem actuallly when the 2nd form opens up and contains "form2.close()" both windows close it also does this when the form2.close() command into the module any ideas why the form can't be terminated by itself? also, i tried creating a sub main() in the module and calling an instance of the first window with showdialoge() then the 2nd form right after with just show() can i has a module as a startup object? Quote
*Experts* mutant Posted October 25, 2003 *Experts* Posted October 25, 2003 The application exits when you terminate the main form becasuse the message loop of your app is dependend on that form. You dont need a module to not directly start with a form. The only thing you need is Shared Sub Main someinwhere in one of your classes: Shared Sub Main() 'do whatever you want when there is no forms or show them. End Sub [\vb] But, if you start a message loop for your form from there it wont make a difference, the application will still be dependent on it. Quote
Æion Posted October 30, 2003 Author Posted October 30, 2003 Where exactly do i put Shared Sub Main() 'do whatever you want when there is no forms or show them. End Sub ? Quote
keitsi Posted April 25, 2004 Posted April 25, 2004 Where exactly do i put Shared Sub Main() 'do whatever you want when there is no forms or show them. End Sub ? In any public module Sub Main() dim frm1 as new Form1 frm1.Show dim frm2 as new Form2 frm2.Show Application.Run 'prevent app from exiting End Sub EDIT: hmmm, whooops.. Sorry, I accidentally woke up this ancient thread :P Quote BS - Beer Specialist
AlexCode Posted April 25, 2004 Posted April 25, 2004 1st thing - Shared Sub Main Mutant told you can be putted where ever you want... not only on modules, this is because it's declared as Shared. 2nd thing - You can close the initial form if... there's allways an If! ... you change the base form that's keeping your app alive. You can see a similar post I made that explains exactlly that at: http://www.xtremedotnettalk.com/showthread.php?t=85196 Alex :p Quote Software bugs are impossible to detect by anybody except the end user.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.