little help! working with system time - Printable Version +- BP Forums (https://bpforums.info) +-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55) +--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56) +---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8) +----- Forum: Programming Help (https://bpforums.info/forumdisplay.php?fid=9) +----- Thread: little help! working with system time (/showthread.php?tid=655) |
little help! working with system time - jochen29 - 09-22-2012 hi everyone.. i have a little problem with time i know the code to get the system time but the problem is as soon i started the program it only gets the time when the program started. what i want is the time or should i say also the seconds,minutes is counting too. Re: little help! working with system time - Vinwarez - 09-23-2012 Hello, jochen29. What you want to do, in order to get full computer's time (without date), is declare four variables and set its values like this: [code2=vbnet]hours = My.Computer.Clock.LocalTime.Hour ' Integer minutes = My.Computer.Clock.LocalTime.Minute ' Integer seconds = My.Computer.Clock.LocalTime.Second ' Integer time = hours & ":" & minutes & ":" & seconds ' String[/code2] If you want your hours, minutes and seconds to update as real time, add a new timer, set its interval to 1000 (1 second), enable it and set the values in timer's sub. It would look like this: [code2=vbnet]Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick hours = My.Computer.Clock.LocalTime.Hour minutes = My.Computer.Clock.LocalTime.Minute seconds = My.Computer.Clock.LocalTime.Second time = hours & ":" & minutes & ":" & seconds End Sub[/code2] Hopefully this solves your problem. |