when i run form from sub Main()
it'll show and disappear in a second.
i have created the object of the form
and use the methon show()
and it does't work
Printable View
when i run form from sub Main()
it'll show and disappear in a second.
i have created the object of the form
and use the methon show()
and it does't work
You have to hold the thread open so you can either use ShowDialog instead of Show or use Application.Run(formtypehere)
Hi,
Just to clarify Edneeis's response,
You create the instance of the form in the General section of the Module:
e.g. Public frmMain As New fclsMain
and then create the following Sub Main.
VB Code:
Public Sub Main() Application.Run(frmMain) End Sub
Just as a note you do not need to declare it in the general section if you don't want you can just assign a new instance in the Application.Run method or just use ShowDialog. Technically you could just call Application.Run() after using Show too, which would hold the thread open but I don't want to confuse you.
VB Code:
Public Sub Main 'you can do this Application.Run(New frmMain) 'or this instead Dim frm As New frmMain frm.ShowDialog() 'or what taxes showed you End Sub
Hi Edneeis,
" Application.Run(New frmMain)"
I did not know that one! Looks like this is my day for picking your brains.
Am I right in saying all three methods will result in the application closing when frm Main is closed, even though other forms were open at that time?
Yes you are right providing there isn't something that would hold things up after the call to Application.Run or ShowDialog. It's all six in one, half a dozen in the other or different ways to do the samething.
:) thanks for the solutions