Display modeless form from Sub Main

R

Rami

My project starts with Sub Main and then needs to display
a modeless form.
From some reason the application closes it self after
calling the Show method.
How can I avoid the application from being closed.
By the way in VB6 there is no problem to do it.
This is the code I have:

Option Explicit On

Module Module1

Public f1 As New Form1()

Sub main()
f1.Show()
End Sub
End Module
 
F

Fergus Cooney

Hi Rami,

Sub main()
f1.Show()
Application.Run
End Sub

Application.Run will start the message pump going so that windows in the
thread (ie f1) have a working message queue.

Regards,
Fergus
 
H

Herfried K. Wagner [MVP]

Hello,


Rami said:
My project starts with Sub Main and then needs to display
a modeless form.
From some reason the application closes it self after
calling the Show method.
How can I avoid the application from being closed.
By the way in VB6 there is no problem to do it.
This is the code I have:

Option Explicit On

Module Module1

Public f1 As New Form1()

Sub main()
f1.Show()
End Sub
End Module

\\\
Application.Run(New Form1())
///
 

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