how to load a form from module?

J

jernej goricki

Hi,
Im trying to load a form from sub main in my module like this:

Module MainModule
Sub main()
Dim StartForm As MainFrame
StartForm = New MainFrame()
StartForm.Show()
End Sub
End Module

But the form just blinks for a second and then it dissapears??
Why??
 
N

Neal Andrews

Pass your form to Application.Run like so,

Module MainModule
Sub main()
Dim StartForm As MainFrame
StartForm = New MainFrame()
StartForm.Show()
Application.Run(StartForm)
End Sub
End Module

Regards
Neal
 
H

Herfried K. Wagner [MVP]

* "jernej goricki said:
Im trying to load a form from sub main in my module like this:

Module MainModule
Sub main()
Dim StartForm As MainFrame
StartForm = New MainFrame()
StartForm.Show()
End Sub
End Module

But the form just blinks for a second and then it dissapears??
Why??

The problem is that your application doesn't have a message loop --
that's why the form will be closed. Use 'Application.Run(StartForm)'
instead of showing the form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top