W
WhiteSocksGuy
Help! I am new to Visual Basic .Net (version 2002) and I am trying to get a
System.Timers.Timer to work for me to display a splash screen for about two
seconds and then load the main form. I have two forms (frmSplash and
frmMain) and a code Module setup as my startup object.
Here is the code that I have, when I try to run this part of the splash
screen form shows and then program terminates. What am I doing wrong?
Thanks,
Kevin
*************************************************************
Module Module1
' Declare the two forms
Public myMain As New frmMain()
Public MySplash As New frmSplash()
Public Class StartUp
Public Shared Sub Main()
' Show the splash screen
MySplash.Show()
' Create a new Timer with Interval set to 2 seconds.
Dim aTimer As New System.Timers.Timer(2000)
' Add an event handler to handle the Elapsed time event
AddHandler aTimer.Elapsed, AddressOf OnTimedEvent
' Only raise the event the first time Interval elapses.
aTimer.AutoReset = False
' Enable the timer
aTimer.Enabled = True
End Sub
Public Shared Sub OnTimedEvent(ByVal source As Object, _
ByVal e
As System.Timers.ElapsedEventArgs)
' Show the main form and hide the splash screen
myMain.Show()
MySplash.Hide()
End Sub
End Class
End Module
System.Timers.Timer to work for me to display a splash screen for about two
seconds and then load the main form. I have two forms (frmSplash and
frmMain) and a code Module setup as my startup object.
Here is the code that I have, when I try to run this part of the splash
screen form shows and then program terminates. What am I doing wrong?
Thanks,
Kevin
*************************************************************
Module Module1
' Declare the two forms
Public myMain As New frmMain()
Public MySplash As New frmSplash()
Public Class StartUp
Public Shared Sub Main()
' Show the splash screen
MySplash.Show()
' Create a new Timer with Interval set to 2 seconds.
Dim aTimer As New System.Timers.Timer(2000)
' Add an event handler to handle the Elapsed time event
AddHandler aTimer.Elapsed, AddressOf OnTimedEvent
' Only raise the event the first time Interval elapses.
aTimer.AutoReset = False
' Enable the timer
aTimer.Enabled = True
End Sub
Public Shared Sub OnTimedEvent(ByVal source As Object, _
ByVal e
As System.Timers.ElapsedEventArgs)
' Show the main form and hide the splash screen
myMain.Show()
MySplash.Hide()
End Sub
End Class
End Module