Label with time?
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
hi, im making a program but there is a problem
for example if i make a alarm for 150 seconds it will show on label "150" and timer will keep -1 from it until "if label.text = 0 then msgbox("alarm!") but
the problem is how can i make the label be real time instead of seconds
like if i choose a 5 min alarm it dont show "300" seconds it show "00:05:00" if 1 hour then "00:60:00"
and how will even i decrease the timer if i use this please help
u dont need to teach but if u have a video or website tell me :P
for example if i make a alarm for 150 seconds it will show on label "150" and timer will keep -1 from it until "if label.text = 0 then msgbox("alarm!") but
the problem is how can i make the label be real time instead of seconds
like if i choose a 5 min alarm it dont show "300" seconds it show "00:05:00" if 1 hour then "00:60:00"
and how will even i decrease the timer if i use this please help

u dont need to teach but if u have a video or website tell me :P
Hi,
Have a look at this - http://www.tutorialspoint.com/vb.net/vb ... e_time.htm
It has properties and methods of the DateTime structure
Have a look at this - http://www.tutorialspoint.com/vb.net/vb ... e_time.htm
It has properties and methods of the DateTime structure
Find my programs on Softpedia
thanks but this just prints out date and time it doesnt teach what i need :/
no no no!
i thin i didnt explain good, here is the reason,
FOR example I made a alarm clock. and I set alarm NOT in exact time like "9:59 AM" i want it to be…
ok look, i have buttons each is like "in 1 hour" "in 3 mins" so when they click it, the alarm is set after 3 mins so it should LOOK like "00:03:00" and then timer will remove 1 sec from it with interval of 1000, until it reaches 00:00:00 the alarm will work.
EVERYTHING is fine with me but I want to know how can i decrease time in this method
if label is 00:13:00 and I do label1.text -= 1 it will not work! thats what i need
i thin i didnt explain good, here is the reason,
FOR example I made a alarm clock. and I set alarm NOT in exact time like "9:59 AM" i want it to be…
ok look, i have buttons each is like "in 1 hour" "in 3 mins" so when they click it, the alarm is set after 3 mins so it should LOOK like "00:03:00" and then timer will remove 1 sec from it with interval of 1000, until it reaches 00:00:00 the alarm will work.
EVERYTHING is fine with me but I want to know how can i decrease time in this method
if label is 00:13:00 and I do label1.text -= 1 it will not work! thats what i need
maybe this helps

Code: Select all
hope this is what you are after Private TDT As DateTime
Private CountFrom As TimeSpan = TimeSpan.FromMinutes(3)
Private Sub form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
timer1.Interval = 500
TDT = DateTime.Now.Add(CountFrom)
timer1.Start()
End Sub
Private Sub Timer1_Tick(sender As Object, e As System.EventArgs) Handles Timer1.Tick
Dim ts As TimeSpan = TDT.Subtract(DateTime.Now)
If ts.TotalMilliseconds > 0 Then
label1.Text = ts.ToString("HH:mm\:ss")
Else
label1.Text = "00:00:00"
tmrCountdown.Stop()
MessageBox.Show("Done")
End If
End Sub

visit us on:
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
To convert seconds to minutes you can also do this
Code: Select all
300 / 60
You can find me on Facebook or on Skype mihai_92b
try this out, THIS CAN HELP YOU BUILD YOUR PROJECT
use "datediff" to calculate the time difference"
here's the full code:
here's the exe file : here's the full project :
use "datediff" to calculate the time difference"
here's the full code:
Code: Select all
Class Form1
Dim startTIME As Date
Dim endTIME As Date
Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label6.Text = "Starting Time : " & startTIME
Label1.Text = "Current time : " & DateAndTime.TimeOfDay
Label2.Text = "Alarm time : " & endTIME
Dim timeDif As Long = DateDiff(DateInterval.Second, startTIME, endTIME)
Label3.Text = "Total Time difference : " & timeDif & " Seconds"
Dim timecounter As Long = DateDiff(DateInterval.Second, DateAndTime.TimeOfDay, endTIME)
Label4.Text = "Remaining time : " & timecounter & " Seconds"
If timecounter <= 0 Then
timecounter = 0
Timer1.Stop()
MsgBox("DONE")
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
startTIME = DateAndTime.TimeString
endTIME = startTIME.AddSeconds(NumericUpDown1.Text) 'add seconds
Timer1.Start()
End Sub
End Class
here's the exe file : here's the full project :
You do not have the required permissions to view the files attached to this post.
Last edited by noypikami on Wed Jan 15, 2014 3:03 pm, edited 2 times in total.
OMG thanks brothers! cryer; loove;
I think the last 2 ones are what i need i will try them now and say if it work
thanks omg; wahooo; loove;
I think the last 2 ones are what i need i will try them now and say if it work


hey dummy
in timer tick event
ts.ToString("HH:mm\:ss") shows to be an error :/
"Overload resolution failed because no accessible 'ToString' accepts this number of arguments."
:3
in timer tick event
ts.ToString("HH:mm\:ss") shows to be an error :/
"Overload resolution failed because no accessible 'ToString' accepts this number of arguments."
:3
Copyright Information
Copyright © Codenstuff.com 2020 - 2023