Solved

Changing System Clock within a Window

Posted on 2000-05-04
6
159 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

734 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