Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
little help! working with system time
#1
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.
#2
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.
Also known as Rocketalypse.
System.out.println("I prefer Java.");


Possibly Related Threads…
Thread Author Replies Views Last Post
  how do you make a register system in VB using Dropbox Cecilio 2 13,962 08-15-2013, 08:14 AM
Last Post: Cecilio
  DotNetBar not working... Please help. Ecnarf 0 6,276 02-12-2013, 08:18 PM
Last Post: Ecnarf
  Help w/ my new operating system Gamester699 5 20,290 07-24-2012, 12:50 PM
Last Post: Vinwarez
  making a windows login system Bradley 3 13,897 05-29-2012, 04:47 PM
Last Post: brandonio21
  Plugin System? zmanalpha 2 11,699 12-19-2011, 02:56 PM
Last Post: zmanalpha

Forum Jump:


Users browsing this thread: 1 Guest(s)