Is there a way to change the system time through VB. I found datetime.time control but I am at a loss on how to pass the new value to it.
Could anyone help me???
Thanks
Printable View
Is there a way to change the system time through VB. I found datetime.time control but I am at a loss on how to pass the new value to it.
Could anyone help me???
Thanks
use the Time statement :)
VB Code:
Time = "12:00:00 PM"
I think that works
Thanks for the response!!
I tried that but I couldn't get it to work. However, I did find a function called timevalue which turns a string value into a usable to value for the time command.
'you have to double click the clock icon in the systray for it to take effect
Private Sub Form_Load()
Dim MyTime
MyTime = "11:00:00 PM"
Time = MyTime
End Sub
In the situation I need this in that would not be acceptable.
Private Sub subSetTime()
Dim tmpMin As String
Dim tmpTime As Variant
Dim tmpDelim As String
Dim tmpHour As Integer
If Len(cmbMins.Text) = 1 Then tmpMin = "0" & cmbMins.Text Else tmpMin = cmbMins.Text
If Val(cmbHrs.Text) > 12 Then
tmpHour = Val(cmbHrs.Text) - 12
tmpDelim = " PM"
Else
tmpDelim = " AM"
tmpHour = cmbHrs.Text
End If
tmpTime = TimeValue(Val(tmpHour) & ":" & Val(tmpMin) & ":00" & tmpDelim)
Call SetTime(tmpTime)
I got a French computer... ;Does the time have to be entered as american time or International time (10:00 pm = 22:00):confused:
Code:'the system time is changed
'but if you want to see the changed time in the systray
'you have to double click the clock icon in the systray for it to take effect
'
'to test it run the code..your msgbox will give you the system time of 11 oclock pm
Private Sub Command1_Click()
MsgBox Now
End Sub
Private Sub Form_Load()
Dim MyTime
MyTime = "11:00:00 PM"
Time = MyTime
End Sub
Mastermind.
just do a msgbox now in some event and see how your time is displayed and act accordingly.
Mastermind. . . . . .
The time format is in international time 10:00pm = 22:00. If you look at the tmphours line I am converting the time from international to american. You will need to expirement with the code.
The SetTime sub uses the DateTime.Time function to set the time for me. If you have any other questions regarding it let me know.