Solved

Changing System Clock within a Window

Posted on 2000-05-04
6
158 Views
Last Modified: 2010-08-05
Is it possible, with Visual Basic, to change the system clock just for a given window?  i.e. without affecting other windows.
0
Comment
Question by:jrossi2000
6 Comments
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2779158
No.
0
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2779159
The system clock applies to the system.  However, you can use a timer within your program and have it go off every second.  You can adjust that to be whatever you want.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2779358
You can use the system time to calculate a new relative time for your application.  Using DateAdd() to convert NY time to LA time:

Private Sub Timer1_Timer()
    Debug.Print DateAdd("h", -3, Time)
End Sub
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Expert Comment

by:pramesh
ID: 2779889
You can change the system clock using Win32Api functions. You have to write code to change system clock. Set your choice for that particular window and then reset it for other windws. Remember, it will effect to the whole operating system.
or
use DATEADD function in vb to add dates etc. In this it won't effect other windows.
0
 
LVL 5

Expert Comment

by:Voodooman
ID: 2779999
Hi

You can change the time really easy by just using the time function

time="10:10:00" sets the time on your PC to 10 past.

Get the time when you load the form

'Form Level variables
'********************
Dim mytime,timediff

mytime=now

'now change the time
time="12:12"

'get your change
'***************
timediff=mytime-now


when you close the form recalculate the date and time


mytime=now+timediff

'now reset date and time
'***********************
date=format(mytime,"Short Date")
time=format(mytime,"hh:mm:ss")



This should do it

Dont just use just the time in case you roll over midnight - using just the time will cause problems

Voodooman!
0
 
LVL 9

Accepted Solution

by:
GivenRandy earned 75 total points
ID: 2780418
No.  As others have confirmed, by inference.  You can use a different time to act as a "new" clock, or you can use an offset from the "real" system clock.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now