Hi i have problem with my timer. when application run it does not go to the timer at all.I have no idea where do i need to troubleshot anymore. Please help if anyone know !

If CheckStatusStr = "0" Then
                    Update_CurrBal()
                    SuccessfullySave()
                ElseIf CheckStatusStr = "1" Then
                    timercount = 0
                    Timer2.Enabled = True
                    Timer2.Start()
                    End If
                Application.DoEvents()
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
            If timercount > 5 Then
            Timer2.Enabled = False
            PaymentDone()
        Else
            timercount += 1
            End If
    End Sub

Have you set the timer.enabled=true? what is the time interval u have given ?

yes. i have use enable.true and i have set interval = 1000 at property list

If CheckStatusStr = "0" Then
       Update_CurrBal()
       SuccessfullySave()
       ElseIf CheckStatusStr = "1" Then
       timercount = 0
        Timer2.Enabled = True
       Timer2.Start()
       End If
       Application.DoEvents()

Any time control is going to Timer2_Tick event? Is timerCount is getting greater than 5 any time?

yes...it goes more than 6...so if more than 5 i have set it to go to the function again and check whether the status is "0" or "1"
if the status is "1" i make it to loop again

So where exactly is your problem? timer is firing fine, Count is getting greater than zero. Where is the problem?

the timer doesn't work at all if i run the application (by mean it doesn't go to the timer function at all) but when i use debug breakpoint and debug line by line it goes to the timer function and work as it suppose to be . So now i don't know whats wrong with my code actually.

Please help ! what might be the problem....am not able to detect it !

try setting the timer enable at proprties where u set the time.
And make sure that the function or method in which ur using the timer is firing and running fine.

swathys, perhaps you can post more code. that would be really useful. .aspx and the .cs parts.
I can copy and paste into my visual studio and see what's going on.

this is the sample code...exactly i use in my application

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        PaymentDone()
        Debug.Print("application end")
        End
    End Sub
Public Sub PaymentDone()

        CheckServerStatus()

        If CheckStatus = "0" Then
            MsgBox("0")
        ElseIf CheckStatus = "Good" Then

            timercount = 0
            Timer2.Interval = 1000
            Timer2.Enabled = True
            Timer2.Start()
        End If
        Application.DoEvents()
        Debug.Print("after timer")
        End Sub
Public Function CheckServerStatus() As String

        CheckStatus = "Good"

        Return CheckStatus

    End Function
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        If timercount > 1 Then
            Timer2.Enabled = False
            Debug.Print("goto paymentDone")
            PaymentDone()
        Else
            timercount += 1
            Debug.Print(timercount)
        End If
    End Sub

after execute this code

ElseIf CheckStatus = "Good" Then

            timercount = 0
            Timer2.Interval = 1000
            Timer2.Enabled = True
            Timer2.Start()
        End If
        Application.DoEvents()
        Debug.Print("after timer")
        End Sub

it goes to

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        PaymentDone()
        Debug.Print("application end")
        End
    End Sub

and end the application.This is what happen after i run my application. It doesn't goto timer at all.

if i remark "end" and run the application it works perfect but i need to use "end" to exit the application if it meet the condition
"If CheckStatus = "0" Then" and "If CheckStatus = "1" then" it suppose to loop (execute timer)until it meets "If CheckStatus = "0" condition

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        PaymentDone()
        Debug.Print("application end")
       ' End
    End Sub

anyone knows whats the problem wt my code....what i have missed out....still not able to find the solution

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.