0

So, I am making a login screen for my application and when you login correctly, it should open form2. But, when I do login correctly it opens form2 then closes it very quickly. Here is my code. (I am using bunifu buttons and text-boxes)

Private Sub BunifuThinButton21_Click(sender As Object, e As EventArgs) Handles BunifuThinButton21.Click
    If BunifuTextbox1.text = "admin" And BunifuTextbox2.text = "adminpass" Then
        Me.Close()
        Form2.Show()
    Else
        If BunifuTextbox1.text = "" And BunifuTextbox2.text = "" Then
            MsgBox("No Username Or Password Found!", MsgBoxStyle.Critical, "Error")
        Else
            If BunifuTextbox1.text = "" Then
                MsgBox("No Username Found!", MsgBoxStyle.Critical, "Error")
            Else
                If BunifuTextbox2.text = "" Then
                    MsgBox("No Password Found!", MsgBoxStyle.Critical, "Error")
                Else
                    MsgBox("Invalid Username And/Or Password!", MsgBoxStyle.Critical, "Error")
                End If
            End If
        End If
    End If
End Sub
Vixro
  • 13
  • 1
  • 7
  • Change 'form2.show' to 'form2.showdialog' – peterG Jul 15 '17 at 16:08
  • Oh, I just looked at it and it is. Sorry about that. Got it fixed, though! – Vixro Jul 15 '17 at 16:14
  • Alternatively, you can change the "Shutdown mode" settings in properties from "When startup form closes" to "when last form closes", and then in your code, run `Form2.Show()` before `Me.Close()`. That ensures the current form isn't the last one so your app won't close and you can do it without `ShowDialog()` which is for dialog boxes. – Fabulous Jul 15 '17 at 16:22
  • @Fabulous : That is what the duplicate is about. – Visual Vincent Jul 16 '17 at 11:37
  • @VisualVincent noted, thanks – Fabulous Jul 16 '17 at 16:40

0 Answers0