Guest User

Untitled

a guest
Aug 24th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. VB.NET: Problem with Multiple Forms
  2. Public Class frmSplashScreen
  3.  
  4. Private Sub tmrSplashScreen_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrSplashScreen.Tick
  5. Me.Hide()
  6. frmLogin.Focus()
  7. frmLogin.Show()
  8. End Sub
  9.  
  10. End Class
  11.  
  12. Public Class frmLogin
  13.  
  14. Public userName As String
  15. Public passWord As String
  16.  
  17. Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
  18.  
  19. End
  20.  
  21. End Sub
  22.  
  23. Private Sub cmdSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSubmit.Click
  24.  
  25. userName = txtUsername.Text
  26. passWord = txtPassword.Text
  27.  
  28. If userName = "Admin" And passWord = "12345" Then
  29. MsgBox("Access Granted! Welcome to BYTE!", MsgBoxStyle.Information, "Byte EGC Payroll System")
  30. Me.Close()
  31. frmMainMenu.Show()
  32. frmMainMenu.Focus()
  33. Else
  34. MsgBox("Access Denied!", MsgBoxStyle.Critical, "Byte EGC Payroll System")
  35. End If
  36.  
  37. End Sub
  38.  
  39. Public Class frmMainMenu
  40.  
  41. Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
  42.  
  43. End
  44.  
  45. End Sub
  46.  
  47. Private Sub frmMainMenu_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  48.  
  49. Me.WindowState = FormWindowState.Maximized
  50.  
  51. End Sub
  52.  
  53. Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
  54.  
  55. MsgBox("Byte" & vbCrLf & "By: JU-CHAN", vbInformation, "Byte Payroll System")
  56.  
  57. End Sub
  58.  
  59. Module modMain
  60. 'In a module
  61. Public frmSpl As frmSplash
  62. Public frmMain As frmMainMenu
  63.  
  64. Public Sub Main(ByVal args() as String)
  65. dim frmLogin as New frmLogin
  66.  
  67. 'Assume frmLogin is a modal form
  68. frmLogin.Show
  69.  
  70. 'A public property set on the Login form
  71. If frmLogin.Passed = True Then Do
  72. 'Load and display the splash screen
  73. frmSpl = New frmSplash
  74. frmSpl.Cursor = Cursors.WaitCursor
  75. frmSpl.Show()
  76. Application.DoEvents()
  77.  
  78. 'If there is any code needed to run before displaying the Main Form
  79. 'do it here
  80.  
  81. frmMain = New frmMainMenu
  82.  
  83. 'Begin running standard application loop for frmMainMenu
  84. Application.Run(frmMain)
  85. End If
  86. End Sub
  87. End Module
  88.  
  89. Public Class frmMainMenu
  90.  
  91. Private Sub frmMainMenu_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  92.  
  93. Try
  94. Me.Cursor = Cursors.WaitCursor
  95. Me.SuspendLayout
  96.  
  97. Me.WindowState = FormWindowState.Maximized
  98.  
  99. 'Put any other loading code needed for this form here
  100. Catch (ex as Exception)
  101. 'Handle exceptions here
  102. Finally
  103. 'Hide the splash screen
  104. frmSpl.Hide()
  105. frmSpl.Dispose()
  106.  
  107. 'Display the form
  108. Me.ResumeLayout
  109. Me.Cursor = Cursors.Default
  110. Me.Show
  111. End Try
  112.  
  113. End Sub
  114.  
  115. tmrSplashScreen.Enabled = False
Add Comment
Please, Sign In to add comment