|
-
Mar 31st, 2004, 08:38 AM
#1
Thread Starter
Hyperactive Member
*RESOLVED* Load a form from main class
I've just started with VB.NET after years of experience in VB 6.0 and I have a little problem.
I've created a class with a sub main. This routine creates a new form which it does just fine, but after that statement it returns immediatly. In VB 6 it would return if the form was closed. The main difference is that I'm expecting the form to take over control, waiting for events and stuff. Because the call just returns my program finishes closing the window.
VB Code:
Public Class Bomberman
Private Shared frmMain As Main
Public Shared Sub Main()
frmMain = New Main() 'VB 6 would return at the moment the form was closed, VB.NET returns immediatly!
frmMain.Show()
End Sub 'because it will return, my app finishes immediatly.
End Class
I found out by creating a new project with a 'startup form' the form would normally load without exiting immediatly. I wanted to know how it did that so I had a look at it's code. I noticed that there was not a single byte different from my forms code. The difference between the projects is that I have a seperate class with a sub main, creating the form, and the other project starts the form by default. How can I find out how to make my form stay without calling it by default?
Last edited by Xa0z; Mar 31st, 2004 at 10:56 AM.
-
Mar 31st, 2004, 09:39 AM
#2
Thread Starter
Hyperactive Member
Is the problem not clear? thought it was a very basic thing :S
-
Mar 31st, 2004, 09:49 AM
#3
Fanatic Member
VB Code:
Public Class Bomberman
Private Shared frmMain As Main
Public Shared Sub Main()
frmMain = New Main()
frmMain.ShowDialogue()
'u can also use Application.Run("frmMain")
End Sub
End Class
-
Mar 31st, 2004, 10:16 AM
#4
Frenzied Member
Yeah, Application.Run(frmMain) is the usual way of doing it.
The other command above is ShowDialog, not ShowDialogue. But maybe that's a locale setting.
-
Mar 31st, 2004, 10:55 AM
#5
Thread Starter
Hyperactive Member
Ah, thanks, works just great!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|