Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 12-09-2011, 06:31 AM   #1
Solid State Member
 
Join Date: Oct 2011
Posts: 17
Default COunt down timer in vb.net

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!
__________________

lanche26 is offline   Reply With Quote
Old 12-16-2011, 11:19 AM   #2
Site Team
 
celegorm's Avatar
 
Join Date: Sep 2006
Posts: 10,713
Send a message via AIM to celegorm
Default

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
__________________

__________________
"as a fanboy i refuse to admit it and will pull countless things out of my butt to disprove it"

Team Thelegorm! Total Kills: 21 (i iz in uor profile, editsing your sigz)
celegorm is offline   Reply With Quote
Old 12-20-2011, 06:30 AM   #3
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 7,999
Default

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
__________________
I didn’t fight my way to the top of the food chain to be a vegetarian…
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 05:39 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0