Good day guys! I have a question in VB.NET. While creating and testing my GUI for a login screen to show up the main page of the payroll system, there's this problem.
The splash screen loads normally, and the login form appear. I type my username and password (e.g. Username: Admin, Password: 12345) and login was successful. Here's the problem: When the Main Menu shows up, the Login screen appears AGAIN, which is at this time, that screen should be already closed. Did I have any problem with the use of Show, Hide, and Close?
Here's my code for the three forms.
A. Splash Screen
Public Class frmSplashScreen
Private Sub tmrSplashScreen_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrSplashScreen.Tick
Me.Hide()
frmLogin.Focus()
frmLogin.Show()
End Sub
End Class
B. Login Form (for system access)
Public Class frmLogin
Public userName As String
Public passWord As String
Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
End
End Sub
Private Sub cmdSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSubmit.Click
userName = txtUsername.Text
passWord = txtPassword.Text
If userName = "Admin" And passWord = "12345" Then
MsgBox("Access Granted! Welcome to BYTE!", MsgBoxStyle.Information, "Byte EGC Payroll System")
Me.Close()
frmMainMenu.Show()
frmMainMenu.Focus()
Else
MsgBox("Access Denied!", MsgBoxStyle.Critical, "Byte EGC Payroll System")
End If
End Sub
End Class
and lastly:
C. Main Menu.
Public Class frmMainMenu
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
End
End Sub
Private Sub frmMainMenu_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.WindowState = FormWindowState.Maximized
End Sub
Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
MsgBox("Byte" & vbCrLf & "By: JU-CHAN", vbInformation, "Byte Payroll System")
End Sub
End Class
Help is greatly appreciated. Thank you! :)