hi guys!

it's my first post on vb.net, it's just that u can't develop on windows 7 anymore using vb6, guess we'll just have to get used-huh.

i'm developing this procedure using a timer object.the thing is the procedure is not in the timer's event procedure but i want it to depend on the timer's interval when executing, it's
just not calling the timer procedure.

how can u declare objects and use their event procedures in code.

thanks.

See if this helps for calling certain events.

'//-------- Pre-requisites: 1 Button, 1 Timer. ----------\\
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "1"
        Timer1.Start()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Text += 1
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Button1_Click(sender, e) '// call event.
    End Sub
End Class

And this for calling procedures.

'//-------- Pre-requisites: 1 Timer. ----------\\
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "1"
        Timer1.Start()
    End Sub

    Private Sub someProcedure()
        Me.Text += 1
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Me.someProcedure() '// call procedure.
    End Sub
End Class

Btw, welcome to vb.net forum. :)

Hi Sarama2030

Create a form, add a textbox and a label and add this code

Private WithEvents Timer1 As System.Windows.Forms.Timer

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Timer1 = New System.Windows.Forms.Timer
        Timer1.Interval = 1000
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Enabled = Not Timer1.Enabled
    End Sub

    Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Text = Now.ToString("HH:mm:ss")
    End Sub

Once the Timer is enabled, the timer_tick event will fire every 1000 milliseconds until it is un-enabled.

This question has already been answered. Start a new discussion instead.