Disposing of a log in window

D

Damian

Hi !

I am trying to dispose of the startup form in my application a login
form (frmLogin) after it calls the main form (frmMain). I cant seem to
get it to work. Here is my code.

frmLogin Code
==============

Sub btnSave_Click

Dim mainF As New frmMain

mainF.Show()
Me.Dispose()

End Sub

The main form flashes up and then the whole app closes down as it goes
to the next line (Me.Dispose()). What needs to happen is the main form
loads then the login form is not visible and unloaded from memory.

Any help is appreciated, thanks !
 
K

Ken Tucker [MVP]

Hi,

Use mainF.ShowDialog instead of mainF.Show. Showdialog will
wait until the form is closed before executing the next line of code.

Ken
 
C

Cor

Hi Damian,

I had this problem yesterday also when I was making a sample from a splash
form.
Today I thought let find somebody else find this solution for you, but
thinking it over it is simple.

I hope this helps?

Cor

\\\
private frm as new form2
Private WithEvents timer1 As New Windows.Forms.Timer
Private Sub Form1_Load(ByVal sender _
As Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
timer1.Enabled = True
timer1.Interval = 12500
frm.Show()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles timer1.Tick
if frm.readyswitch = true then 'readyswitch as public variable
frm.Close()
frm.Dispose()
timer1.Enabled = False
end if
End Sub
///
 

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