Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted
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.
To err is human, to really foul things up requires a computer.
Posted

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?

  • *Experts*
Posted

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.

  • 5 months later...
Posted
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

BS - Beer Specialist
Posted

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

Software bugs are impossible to detect by anybody except the end user.

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...