|
-
Dec 23rd, 2002, 07:39 AM
#1
Thread Starter
New Member
Load forms through Sub Main
Hi,
We have developed a Windows Application using vb.net. In this project, we have
a public Module file and couple of Windows forms. we have a procedure named Main in the
module file and we would like to load a form through this sub-routine. The code snippet
is given below for your reference.
Public Module Module1
Public obj_frm_Test As New frmTest()
Public Sub Main()
obj_frm_Test.Show()
End Sub
End Module
In frmTest, we have few windows controls to do the required processing. We set
Sub Main as the startup objeect using project properties dialog box. Whn we execute
our project now, frmTest comes to the foreground and it gets unloaded automatically by itself.
Our understanding about this is, when Sub Main procedure goes out of scope, objects created
inside this sub routine is destoryed automatically.
Here, instead of Show(), when we use ShowDialog(), form stays in the foreground, we expect
Show() function to behave in the similar way. The same piece of code when we execut it from
Visual Basic 6.0, it works as we expect.
Can you tell us what needs to be corrected in the above code, we look forward
for your reply, thank you.
Regards,
Deva.
-
Dec 23rd, 2002, 07:58 AM
#2
Fanatic Member
Deva
You have to use the ShowDialog() method of the form if you want the form to remain in the foreground.
VB Code:
' VB6
frmTest.Show vbModal
' This is the VB.NET equivalent
'
frmTest.ShowDialog()
Using VB.NET 2003/.NET 1.1/C# 2.0
http://del.icio.us/rajoo
Blow your mind, smoke gunpowder
Ashes to ashes, dust to dust
If God won't have you, the devil will. - Author unknown
Don't follow me, I'm lost too ...
-
Dec 23rd, 2002, 09:24 AM
#3
The preferred way to load your first form from sub main would be
Dim youform As New Form1
Application.Run(yourform)
This will run the form non modal I believe but will also keep your app running until you close that form.
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
|