Note that there are some explanatory texts on larger screens.

plurals
  1. POVB.NET application firing Shutdown event on form close
    primarykey
    data
    text
    <p>I have a VB.NET app that is behaving strangely (or perhaps not strangely at all and I'm just missing something).</p> <p>I have a login form that when the user clicks OK and logs in successfully it loads the main application form.</p> <p>However when I show the main form and close the login form, the app is firing the shutdown event.</p> <p>Is this because the app thinks that the login form is the only form open and thus fires the shutdown event?</p> <p>Here is the code for the login routine, when I call Me.Close() at the end is when the shutdown event is fired. Am I doing things out of order? I used to do it this way in VB6 with no problems (I know they're a lot different).</p> <p>Note, it's nothing in frmMain either, this happens no matter what form I try to open.</p> <p>Thanks.</p> <pre><code>Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click 'iLoginResult = 0 : Success ' 1 : Invalid user name or password ' 2 : Other login error ' 3 : User not authorized Dim iLoginResult As Integer = 2 Dim sTopLabel As String = "" Dim sBottomLabel As String = "" Me.Cursor = Cursors.WaitCursor Try If Me.txtUserName.Text.ToString.Trim = "" Or Me.txtPassword.Text.ToString.Trim = "" Then MessageBox.Show("Enter a user name and password before continuing.", "DocGen", MessageBoxButtons.OK, MessageBoxIcon.Warning) Exit Try End If iLoginResult = modGeneral.bLogin(Me.txtUserName.Text.ToString.Trim, Me.txtPassword.Text.ToString.Trim) Select Case iLoginResult Case 1 : sTopLabel = "The user name or password is incorrect" : sBottomLabel = "Check your user name then type your password again." Case 2 : sTopLabel = "General login error" : sBottomLabel = "Contact your information technology department." Case 3 : sTopLabel = "Unauthorized access" : sBottomLabel = "Contact your information technology department to gain access to this system." End Select If iLoginResult &gt; 0 Then RaiseDialog(sTopLabel, sBottomLabel) Me.txtPassword.Text = "" Me.txtUserName.Focus() Me.txtUserName.SelectAll() End If Catch ex As Exception RaiseError("", "frmLogin.btnOK_Click", Err.Number, Err.Description) End Try Me.Cursor = Cursors.Default If iLoginResult = 0 Then If Me.cmbEnvironment.Text = "Development" Then modGeneral.gbIsProduction = False frmMain.Show() Me.Close() End If End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload