Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Question]CountDown
#1
Ok, here is my countdown codes and pictures.

Code:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label1.Text = Val(TextBox1.Text)
        Timer1.Start()
        Label4.Text = ""
        Label5.Text = ""
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Text = Label1.Text - 1
        If Label1.Text = "0" Then
            Timer1.Stop()

        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer1.Stop()
        Label1.Text = ""
        Label4.Text = "You have stoped the countdown"
        Label5.Text = "Please make a new timer"
    End Sub

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

[Image: 10qzy8o.jpg]

[Image: 2ldau5h.jpg]


My point is. When i click Start, it FAST, very fast, what is the correct code to make it go slower? I did make some of that code up.

Another question.

When i press Stop, the time ends. Is there Anyway i could make it so it could start where i stoped it at?

Oh yeah btw this took me about 10 minutes to do. I'm new to Visual Basic, so please don't make fun of this ;).
Reply
#2
@ ?1 set the timer interval in the timer1 properties to like 5000, that would be 5 seconds in milliseconds.

@ ?2 what do you mean, like start the count of where the count left off at?
~ Digital-Punk
Reply
#3
Ahh, Thanks for number 1, ill test it out..

In 2 i mean. It is counting like like from 100

It's now like 95 for example. I press stop..

And if i press start again it goes again to 100, unless i change it to 95.. And I hate constantly changing if i have to pause it /Stop it..
Reply
#4
I'm assuming for number 2 you want to resume the countdown where it left off. In this case you should make a total of 3 buttons, Start, Pause/Resume (or Stop/Resume), and Reset.

You want the Start button to obviously start the countdown. Now your Pause button will temporarily pause the countdown where its at AND it will resume your countdown. Your Reset button will turn the countdown off and reset it to 0(zero) for a new countdown.

Ok, let's say your countdown Starts at 100, a few moments later its at....80. Now you want to hit the Pause/Resume button and it will "freeze" the time in its place. To have your Pause/Resume function to work properly I would suggest using a boolean.

An example would be:
Code:
**NOTE** THIS IS C# SYNTAX WHICH IS VERY SIMILAR TO VB.NET

bool countdownPause = false;

//Now when your button is clicked you want to change your bool
//countdown to true.
//When the countdown is true the timer will Pause until countdownPause
//bool is false.

I hope this help's you on your project! Please PM me if you need additional assistance. Smile
Reply
#5
algorithm

Thank you so much for number 1. It worked perfectly for me ;).

HatredTrinity

Ok thanks ;). I will try it out. I hope it work.


EDIT::

2. Ok nothing seems to work. But if i make a new button named Resume for example.

I put this code in

timer1.stop()
timer1.start()

And when i press it. It stops for a second and start again where it started from...

If i click like 10 times in row. It just is paused then i let go, it goes back..

So i kinda got the right code but i need to edit it somehow to make it i press once for pause and other one to resume it.
Learning Visaul Basic Express Edition ^^
Reply
#6
Here is the correct code for the pause/resume button:
Code:
if timer1.enabled=true then
  timer1.enabled=false
elseif timer1.enabled=false
  timer1.enabled=true
End If
My software company: Porosis Software
Games: Terrantula
Apps: Mathanasis, ColorGrabber
Reply
#7
Thank you so much! Finally my countdown is perfect! Thanks to SF members Smile. Tyvm guys all who helped.
Learning Visaul Basic Express Edition ^^
Reply
#8
no problem anytime!
~ Digital-Punk
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Question] Countdown 2 p1g 0wnz 6 1,281 12-29-2009, 06:20 PM
Last Post: dunlop03

Forum Jump:


Users browsing this thread: 1 Guest(s)