Hi, I am exploring a timer function which I wants my program function runs every 10 minit interval. Below is my coding:

Dim timer As Timer
   timer = New Timer(600000)
        'timer.Enabled = True
        timer.Interval = 600000
        timer.Start()  
       
       'Do function

    timer.Stop()

Actually I am not familiar with timer function, can someone guide me, please? Thanks in advance.

Recommended Answers

All 5 Replies

First of all drag and drop one timer on your application then set Enabled property=True
and set interval="whatever u want in my case 6000" and also take one textbox
And now double click the timer control and write the following code....

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If Timer1.Interval = 6000 Then
            TextBox1.Text = 100
        End If
    End Sub

First of all drag and drop one timer on your application then set Enabled property=True
and set interval="whatever u want in my case 6000" and also take one textbox
And now double click the timer control and write the following code....

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If Timer1.Interval = 6000 Then
            TextBox1.Text = 100
        End If
    End Sub

Hi, I am using console application, and not window form application, sorry for the made you confused.

here is a solution:

There is a timer class specifically for console or rather non ui app. which is SYSTEM.THREADING.TIMER , you will have to use it.

Module Module1

    Sub Main()

        Dim tmr As System.Threading.Timer
        Dim tmrCallBack As New System.Threading.TimerCallback(AddressOf DoFuntion)
        tmr = New System.Threading.Timer(tmrCallBack, Nothing, 0, 1000) 'do function will be called ever 1 sec.
        Console.ReadLine()

    End Sub

    Public Sub DoFuntion(ByVal state As Object)
        Console.WriteLine("Do Function Called")
    End Sub

End Module

If I wants to put the coding above into window service application, does it works?

I thinks it is works, thanks you all:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.