I have a very generic login form created that allows a user to access a application. My problem is getting the log in form to close after the application form is loaded. I have described the specifics in the comments of the code. Any help would be greatly appreciated.
Public Class frmUserLogin
Inherits System.Windows.Forms.Form
Private pass As String
Private username As String
Private attempt As Integer = 0
Private Admin As String
Private Password As String
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
username = "Admin"
pass = "Password"
If (txtUsername.Text = username) And (txtPassword.Text = pass) Then
MsgBox("That is correct")
frmApplicationWindow.Show()
'I am trying to close the login form after the user is able to load the frmapplicationwindow
'frmUserLogin.close() , when I use this it says I can use it because it is referring to the same instance of itself
'me.close , when I use this it closes both the user login form and the application form
Else
MsgBox("wrong username or pass, try again")
attempt += 1
End If
If attempt = 3 Then
MsgBox("You have reached the allowed number of login attempts")
Me.Close()
End If
End Sub
End Class
Just use Me.Hide in place of Me.Close.