COunt down timer in vb.net

lanche26

Solid State Member
Messages
17
Good readings everyone.... i want to make a countdown timer in vb.net. this is what i got


Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

dim x as integer = textbox1.text
dim y as integer = 60
dim ans as integer = x * y


label1.text = ans - 1

end sub

if i input one in the textbox and run the program it only change the text in the label box as 59, its like its counting down but only once. how could i do it! please help me!
 

Celegorm

Site Team
Staff member
Messages
11,741
Location
USA
what is the x * y supposed to do?

Not sure how it works in VB, but there should be a way to do something like the following:

private sub textbox1.textChanged
integer x = 60 (or whatever your limit is)
label1.txt = x - textbox1.size
 

root

Site Team
Staff member
Messages
8,181
Location
UK
Umm,
you get the value of X at the start of each time the timer ticks.

the text box value appears to be set at 1.

get value from text box (=1),
times 60, (=60)
minus 1 (=59)
write result to label.

then it starts again.

you need to either read the label, or change the value in the text box.
Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

dim x as integer = textbox1.text
dim y as integer = 60
dim ans as integer = x * y
textbox1.text = ans - 1

end sub
 
Top