Count down timer [VB .NET]

Forum rules
- Ask questions about or share code from languages other than Source Engine scripting.
- Start new topic titles with the code language in brackets (i.e. [C#], [C++], [PHP], etc.)
User avatar
killman2639
Former Server Admin
Posts: 292
Joined: Mon Aug 23, 2010 8:41 pm

Count down timer [VB .NET]

Post by killman2639 »

Hello everyone, i wanted to ask you all how to make a count down timer with only one timer (seconds) but including the hours and minutes(i.e. You can write the hours mins and secs you want (input) it to wait then make it count down with the secs timers) im sure i have to use if statements (If Label14.Text = "00" And Label15.Text = "00" And Label16.Text = "00" Then) something like that but im not sure.

thanks.

EDIT: Also could you tell me how to convert a String to an Integer. Ive tried Convert.ToInt32(textbox1.text) but didnt work
Hi, I'm Reloaded. :)

Image

Code: Select all

[GR|CMX] Reelawded | Reloaded :  hi, im black
[GR|CMX] Reelawded | Reloaded :  shit
Disconnect: being black.
Disconnect: being black.
User avatar
nick_6893
Site Admin
Posts: 668
Joined: Fri Apr 09, 2010 4:09 pm

Re: Count down timer [VB .NET]

Post by nick_6893 »

Hmm try this out. I don't know if this will work as I use visual basic 6 at school.

Val(Whatever.text)

Val = Value.
User avatar
killman2639
Former Server Admin
Posts: 292
Joined: Mon Aug 23, 2010 8:41 pm

Re: Count down timer [VB .NET]

Post by killman2639 »

nick_6893 wrote:Hmm try this out. I don't know if this will work as I use visual basic 6 at school.

Val(Whatever.text)

Val = Value.
thanks nick, that works too. But i used this:

Code: Select all

         Try
            sec = TextBox3.Text
            Label16.Text = sec.ToString
        Catch ex As Exception
            Label16.Text = "0"
            TextBox3.Text = "0"
            TextBox3.SelectAll()
        End Try
EDIT: I might be posting the program when its done :)
Hi, I'm Reloaded. :)

Image

Code: Select all

[GR|CMX] Reelawded | Reloaded :  hi, im black
[GR|CMX] Reelawded | Reloaded :  shit
Disconnect: being black.
Disconnect: being black.
User avatar
Blake
500+ Posts
500+ Posts
Posts: 588
Joined: Mon Jul 05, 2010 8:51 pm
Location: Ontario, Canada

Re: Count down timer [VB .NET]

Post by Blake »

killman2639 wrote:Hello everyone, i wanted to ask you all how to make a count down timer with only one timer (seconds) but including the hours and minutes(i.e. You can write the hours mins and secs you want (input) it to wait then make it count down with the secs timers) im sure i have to use if statements (If Label14.Text = "00" And Label15.Text = "00" And Label16.Text = "00" Then) something like that but im not sure.

thanks.

EDIT: Also could you tell me how to convert a String to an Integer. Ive tried Convert.ToInt32(textbox1.text) but didnt work

Code: Select all

Convert.ToInt32(TextBox1.Text.ToString())
By the way for the count down I would make a new thread and use multi-threading to you'r advantage or use a background worker
Unkown wrote: Life’s too short to worry about the little things.
Albert Einstein wrote: You do not really understand something unless you can explain it to your grandmother.
User avatar
killman2639
Former Server Admin
Posts: 292
Joined: Mon Aug 23, 2010 8:41 pm

Re: Count down timer [VB .NET]

Post by killman2639 »

Smacked wrote:

Code: Select all

Convert.ToInt32(TextBox1.Text.ToString())
By the way for the count down I would make a new thread and use multi-threading to you'r advantage or use a background worker
Thanks smacked, ill edit the program right away.

EDIT: i know ull call me new but i tried this and it doesnt send any errors but it does not do the thing inside the if()

Code: Select all

Convert.ToInt32(TextBox3.Text.ToString())
            If TextBox3.Text > 24 Then
                Label16.Text = "0"
                TextBox3.Text = "0"
                TextBox3.SelectAll()
            End If


Whole SUB:

Code: Select all

Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
        Try
            Convert.ToInt32(TextBox3.Text.ToString())
            If TextBox3.Text > 24 Then
                Label16.Text = "0"
                TextBox3.Text = "0"
                TextBox3.SelectAll()
            End If
            sec = TextBox3.Text
            Label16.Text = sec.ToString
        Catch ex As Exception
            Label16.Text = "0"
            TextBox3.Text = "0"
            TextBox3.SelectAll()
        End Try
    End Sub
Hi, I'm Reloaded. :)

Image

Code: Select all

[GR|CMX] Reelawded | Reloaded :  hi, im black
[GR|CMX] Reelawded | Reloaded :  shit
Disconnect: being black.
Disconnect: being black.
User avatar
Blake
500+ Posts
500+ Posts
Posts: 588
Joined: Mon Jul 05, 2010 8:51 pm
Location: Ontario, Canada

Re: Count down timer [VB .NET]

Post by Blake »

DOOOOOOOOOOOOOOOOOOOODEEEEEEEEEEE
you create an integer and then have that new integer = the converted form of that text box or have that convert thing were the text box is in the if statement.
works the same way as Replace() for text ie.

Code: Select all

Dim Blah As String = "Im such a negro"
Blah = Replace(Blah, "negro", "wigger")
'Replaces negro to wigger
by the way what are you trying to make a elapsed time or what ever or a clock?
cuz like i wouldn't use that many text boxes for a clock or timer... or elapsed time
as well it sounds like a GABEN program
Unkown wrote: Life’s too short to worry about the little things.
Albert Einstein wrote: You do not really understand something unless you can explain it to your grandmother.
User avatar
killman2639
Former Server Admin
Posts: 292
Joined: Mon Aug 23, 2010 8:41 pm

Re: Count down timer [VB .NET]

Post by killman2639 »

Smacked wrote:DOOOOOOOOOOOOOOOOOOOODEEEEEEEEEEE
you create an integer and then have that new integer = the converted form of that text box or have that convert thing were the text box is in the if statement.
works the same way as Replace() for text ie.

Code: Select all

Dim Blah As String = "Im such a negro"
Blah = Replace(Blah, "negro", "wigger")
'Replaces negro to wigger
by the way what are you trying to make a elapsed time or what ever or a clock?
cuz like i wouldn't use that many text boxes for a clock or timer... or elapsed time
as well it sounds like a GABEN program
thanks again : p. the program is ready i just have to make an english translation and we all set. Thanks to everyone that helped :D
Hi, I'm Reloaded. :)

Image

Code: Select all

[GR|CMX] Reelawded | Reloaded :  hi, im black
[GR|CMX] Reelawded | Reloaded :  shit
Disconnect: being black.
Disconnect: being black.