How do I show a form?

  • Thread starter Thread starter Daniel Kaseman
  • Start date Start date
D

Daniel Kaseman

Why won't this work?

Dim frm As New Form1()

Me.Close()

frm.Show()

HELP!
 
Daniel,

Are you using the IDE from VBNet to create a program.

The code that you are using now is.
Dim frm As New Form1()
Create an extra form opbject and name it frm
Me.Close()
Close this class and when that is the main class the program
frm.Show()
There is nothing more to show.

I hope this gives an idea, however first answer the first question.

When you use the IDE you have nothing to do and when you than click on debug
it will show a form.

Cor
 
I'm trying to display a stratup screen, and then after 5 seconds, unload the
startup screen from memory, then show the main form.

It just flashes the main form for a fraction of a second, then when the
splash screen closes (me.close) the program closes. It should load the main
screen.
 
Daniel,

In your mainform
\\\
dim frm as new formSplash
frm.showsplash
'formSplasy has by instance a form timer
'and when those event fires (tick) in that me.close
frm.dispose
///

That is in my opinion the most simple one.

I hope this helps,

Cor
 
Daniel, you should do it like this (probably the best way for splashing a
form):

1- Use a separate module for starting your application like this :

Public Module Entery
Public Sub Main()
Dim frm1 As New SplashForm
frm1.Show()
Threading.Thread.Sleep(5000)
frm1.Close()
Application.Run(New Form1)
End Sub
End Module

2- And "SplashForm" is the form you want to splash before the main form (
Form1).

3- Don't forget to set the project start up object to "Sub Main".
 
For better results, use the following module ( Application.DoEvents Is
added):

Public Module Entery
Public Sub Main()
Dim frm1 As New SplashForm
frm1.Show()
Application.DoEvents()
Threading.Thread.Sleep(5000)
frm1.Close()
Application.Run(New Form1)
End Sub
End Module
 

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

Back
Top