|
-
Feb 9th, 2010, 09:58 AM
#1
Thread Starter
Member
VB.NET 2005 - Function based on timer.
I can't seem to get one of my functions to work based on a timer. Every tick of the timer, I'm trying to call a function which will start periodically taking screen shots until the 'Finish' button is pressed. However, I've run into numerous errors and wondered if anyone could give me any insight or suggestions. Here is what I have so far...
Code:
Public Class Form1
Dim ssTimer1 As Timer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.ssTimer1.Enabled = False
End Sub
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
ssTimer1.Interval = 10000
ssTimer1.Enabled = True
AddHandler ssTimer1.Tick, AddressOf RunAC
End Sub
Public Sub RunAC()
< yata yata yata code code code>
End Sub
End Class
One of the errors included "Public Sub RunAC() does not have the same signature as delegate". This might be really obvious, I'm a recent Computer Programmer / Analyst graduate with intermediate VB.net experience. Any help is appreciated.
Last edited by stronius; Feb 9th, 2010 at 10:03 AM.
-
Feb 9th, 2010, 10:17 AM
#2
Re: VB.NET 2005 - Function based on timer.
You need your event sub to have the same signature (parameters) as the event itself for it to be handled so this:
Code:
Public Sub RunAC()
< yata yata yata code code code>
End Sub
becomes:
Code:
Public Sub RunAC(ByVal sender As System.Object, ByVal e As System.EventArgs)
< yata yata yata code code code>
End Sub
-
Feb 9th, 2010, 10:19 AM
#3
Re: VB.NET 2005 - Function based on timer.
Why do you have to declare you timer in code (and never instantiate it) ? And the RunAC sub doesn't have the same signature of a timer.tick event?
It would be a lot simpler if you just drop a timer from the toolbox to your form in the designer and then double click on the timer's icon to create a timer.tick event handler for it.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Feb 9th, 2010, 10:21 AM
#4
Thread Starter
Member
Re: VB.NET 2005 - Function based on timer.
Got it working. Thanks guys. Yeah I forgot all about .NET having a timer control. After adding the Timer control, it made things a lot easier.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|