I have an application with two forms, FrmLogin and FrmMain. When application opens up, FrmLogin pops up for authentication, once successful, FrmMain should open and FrmLogin should close. Looks like I can not close the FrmLogin! Any idea? Thanks.


This is the code behind the Login Button. Unfortunately I can NOT close the FrmLogin once authentication is successful!

VB Code:
  1. Private Sub BtnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLogin.Click
  2.        
  3. If Me.TxtUsername.Text = "User” And Me.TxtPassword.Text = "password" Then
  4.  
  5.    Dim form2 As New FrmMain
  6.         form2.Show()
  7.  
  8. Else
  9.         Me.Close()
  10. End If
  11. End Sub