Exiting an Application on start-up

D

Dave

Hi,

I have created an application with two forms, the main form and a
login form that allows the user to supply a username and password.

In my main form initialisation i have the following:

Sub InitializeForm()
'Open the login box
Dim LoginBox As New FrmLogin
If LoginBox.ShowDialog(Me) = DialogResult.OK Then
mydb = New ClassTimeDB("E:\Databases\Time",_
LoginBox.TxtUserID.Text, LoginBox.TxtPassword.Text)
LoginBox.Dispose()
LoginComplete()
Else
Application.Exit()
End If
End Sub

I have set the OK and Cancel buttons on the login form to return the
OK and Cancel commands in the DialogResult property of the buttons

The OK works fine however, the cancel does not close the application.

Further investigation showed that the Application.AllowQuit property
is set false - so this is obviously why my app won't quit. I guess
this is because the application hasn't fully initialised yet?

How can i accomplish what i want to do?

Thanks in advanced
 
D

Dave

Nope, that causes an exception, giving the reason

Cannot access a disposed object named "FrmMain"
 
C

Cor Ligthert [MVP]

Dave,
Nope, that causes an exception, giving the reason

Cannot access a disposed object named "FrmMain"
LoginBox.Dispose()
LoginComplete()
Else
me.close
End If
End Sub

Strange

Cor
 

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

Similar Threads


Top