Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello can someone help me out how to create this feature:
My.Settings.Time = 10 ( time integer user 10)

And i want when form load Timer1 is starting and reading from My.Settings.Time value
And to start countdown from that value to 0. When value become 0 to show msgbox(work).

Thats what i'm trying to do. To read from My.Settings the value and countdown from it.

What I have tried:

Form1_load
Timer1.Start()

Timer1_Tick:
<pre>Try
            Timer1.Interval = My.Settings.Time
            If My.Settings.Time = 0 Then
                MsgBox("Work")
                Timer1.Stop()
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
Posted
Updated 24-Sep-20 8:56am
Comments
ZurdoDev 24-Sep-20 13:45pm    
Where are you stuck?
diablo22 24-Sep-20 13:46pm    
i cannot manage to do it, my code above not work at all
ZurdoDev 24-Sep-20 13:48pm    
Debug the code and find a specific issue you need help with.
diablo22 24-Sep-20 14:03pm    
it doesnt countdown the value from settings
ZurdoDev 24-Sep-20 14:07pm    
I don't see any code that will countdown. Maybe you mean the timer does not fire?

You have no choice but to learn to use the debugger. It's going to tell you what the values are at any point in your code while it's running.

Set a breakpoint on the If statement, run the code, and then the breakpoint is hit, the code will stop running and show you the line that's going to execute next. Hove the mouse over the Time part of My.Settings.Time and it should show you the current value. If that value is not what you expect, you're going to have to dig into why.
 
Share this answer
 
As mentioned in the comments, declare a class level variable and then in your timer tick event subtract one from that variable and then do your if statement to check the value.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900