Call a procedure

  • Thread starter Thread starter Laurence Nuttall
  • Start date Start date
L

Laurence Nuttall

How can I call a control procedure

call Timer1_Elapsed()

I get :

Argument not specified for paramter 'e' of Private
sub_Timer1_Elapsed(sender as Object, e as System.timers.ElapsedEventArgs)

Thanks in Advance,

Laurence Nuttall
Programmer Analyst III
UCLA - Division of Continuing Education
 
Public Class Form1
Inherits System.Windows.Forms.Form

Private objTimer As New System.Timers.Timer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

AddHandler objTimer.Elapsed, AddressOf OnTimedEvent

objTimer.Interval = 1000
Dim objArgs As System.Timers.ElapsedEventArgs

OnTimedEvent(Me, objArgs)

System.Threading.Thread.CurrentThread.Sleep(2000)
objTimer.Start()
End Sub

Private Shared Sub OnTimedEvent(ByVal source As Object, ByVal e As
System.Timers.ElapsedEventArgs)
Console.WriteLine(Now.ToString & " Hello")
End Sub
 
Hi Laurence,

When you are working with timers have a good look which one you use.

There are 3, mostly are used the system.timers.timer and the
system.windows.forms.timer
(The threading timer is the other one)

The work completly different and also the events signatures are different.

I hope this helps?

Cor
 
* Laurence Nuttall said:
How can I call a control procedure

call Timer1_Elapsed()

I get :

Argument not specified for paramter 'e' of Private
sub_Timer1_Elapsed(sender as Object, e as
System.timers.ElapsedEventArgs)

Remove the 'Call' and pass something for 'sender' and 'e', or even
better: Create a separate procedure and move the code from the 'Elapsed'
event handler to this procedure. Then call this procedure from the
'Elapsed' event handler and at any place you want the handling code to
be executed.
 
Back
Top