Call a procedure

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
 
A

Adrian Forbes [ASP MVP]

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
 
C

Cor

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
 
H

Herfried K. Wagner [MVP]

* 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Pattern Property 4
Capitalize First letter of keywords 1
debug.write 4
public variable not public 5
Can't show form in class Library module 2
An Unhandled Exception 9
ListView Items 3
Modifiers Property of label 4

Top