I'm new to visual basic. I would like to open a new window in VB.NET when I click the log in button. I also wanted to close first the current form so that it will open a new form.
Private Sub btnLogIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogIn.Click
Dim username As String = tbUsername.Text
Dim password As String = tbPassword.Text
If username = "admin" And password = "admin" Then
MsgBox("Log In Successful!", MsgBoxStyle.Information, "Success")
Close()
Dim mainMenu As New MainMenu()
mainMenu.Show()
Else
MsgBox("Log In Failed!" + vbCr + "Wrong credentials!", MsgBoxStyle.Exclamation, "Failed")
End If
End Sub
When I click the log in button, it will display the next form for about 0.10 seconds then close. I also tried mainMenu.ShowDialog()
but it yields the same result. What should I do?