Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- VB.NET: Problem with Multiple Forms
- 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
- 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
- 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
- Module modMain
- 'In a module
- Public frmSpl As frmSplash
- Public frmMain As frmMainMenu
- Public Sub Main(ByVal args() as String)
- dim frmLogin as New frmLogin
- 'Assume frmLogin is a modal form
- frmLogin.Show
- 'A public property set on the Login form
- If frmLogin.Passed = True Then Do
- 'Load and display the splash screen
- frmSpl = New frmSplash
- frmSpl.Cursor = Cursors.WaitCursor
- frmSpl.Show()
- Application.DoEvents()
- 'If there is any code needed to run before displaying the Main Form
- 'do it here
- frmMain = New frmMainMenu
- 'Begin running standard application loop for frmMainMenu
- Application.Run(frmMain)
- End If
- End Sub
- End Module
- Public Class frmMainMenu
- Private Sub frmMainMenu_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- Try
- Me.Cursor = Cursors.WaitCursor
- Me.SuspendLayout
- Me.WindowState = FormWindowState.Maximized
- 'Put any other loading code needed for this form here
- Catch (ex as Exception)
- 'Handle exceptions here
- Finally
- 'Hide the splash screen
- frmSpl.Hide()
- frmSpl.Dispose()
- 'Display the form
- Me.ResumeLayout
- Me.Cursor = Cursors.Default
- Me.Show
- End Try
- End Sub
- tmrSplashScreen.Enabled = False
Add Comment
Please, Sign In to add comment