How do you set the system time in VB.Net Code

L

Laurence

Hi All,

Must be simple I'm sure

but does anyone know how to set the Windows System Time/Clock in VB.NET
code?
 
J

Jim Blizzard [MSFT]

Hi Laurence,

Thanks for posting to the newsgroup.

You could possibly use the Microsoft VB .NET Runtime library
(Microsoft.VisualBasic.dll). In it there is a DateAndTime class that has a
"Today" property. The object browser summary states: "Returns or sets a
Date containing the current date according to your system." There are a
couple of other properties that have similar descriptions. Haven't tried it
myself, but it might be worth a try...

Hope this helps,
bliz

--
Jim Blizzard, MCSD .NET
Community Developer Evangelist | http://www.microsoft.com/communities
Microsoft

Your Potential. Our Passion.

This posting is provided as is, without warranty, and confers no rights.
 
Joined
Nov 14, 2007
Messages
2
Reaction score
0
Set clock in VB.Net

Private Sub btnTimeSet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Try
TimeOfDay = CDate((Me.numHour.Value.ToString + ":" + Me.numMin.Value.ToString + ":" + Me.numSec.Value.ToString))

Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
 
Last edited:
Joined
Nov 14, 2007
Messages
2
Reaction score
0
Private Sub btnTimeSet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Try
TimeOfDay = CDate((Me.numHour.Value.ToString + ":" + Me.numMin.Value.ToString + ":" + Me.numSec.Value.ToString))

Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,075
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top