因sub main()函数 出现问题?
vb.net2003
在msdn 里有这样的例子...每5秒中弹出一个框...
(form里拖一个timer控件...)
程序:
Friend WithEvents Timer1 As System.Windows.Forms.Timer 'timer控件
Private Shared myTimer As New System.Windows.Forms.Timer
Private Shared alarmCounter As Integer = 1
Private Shared exitFlag As Boolean = False
' This is the method to run when the timer is raised.
Private Shared Sub TimerEventProcessor(ByVal myObject As Object, _
ByVal myEventArgs As EventArgs)
myTimer.Stop()
' Displays a message box asking whether to continue running the timer.
If MessageBox.Show("Continue running?", "Count is: " & alarmCounter, MessageBoxButtons.YesNo) = System.Windows.Forms.DialogResult.Yes Then
' Restarts the timer and increments the counter.
alarmCounter += 1
myTimer.Enabled = True
Else
' Stops the timer.
exitFlag = True
End If
End Sub
Public Shared Sub Main()
' Adds the event and the event handler for the method that will
' process the timer event to the timer.
AddHandler myTimer.Tick, AddressOf TimerEventProcessor
' Sets the timer interval to 5 seconds.
myTimer.Interval = 5000
myTimer.Start()
' Runs the timer, and raises the event.
While exitFlag = False
' Processes all the events in the queue.
Application.DoEvents()
End While
但是这样的话, 画面也不会显示, 想实现别的功能也不能实现...
好像每次被 sub main()函数初起化....
请帮我解释sub main()函数, 以及怎样做的话, 画面也能显示,然后也能实现每5秒钟弹出提示框...