Time / System Time / Timer Questions
I actually have two questions, both related to time...
1) I figured out how to show the current system time, but i was wondering how i can compare it to a given time (eg for an alarmclock)
2) I wanted to create a clock, that starts at 00:00 and runs ten times as fast as a normal clock, and that i can adjust while its running (eg + 1h, -1h, etc...)
Many thx in advance! (i would also really appreciate tutorials that are related to time, timers, etc)
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
System Time Vs Timer Help
Hi
i'll just started a new program. The program i have need to show the form starting time and update the time in a label in the background while the user uses other function on the program like calculating functions, login / search section etc...
The program need to record the section time and update it every secound while other function is used by others
I'm kind of stuck on the idea>.< and stuck on the code
To keep everything simple I want it just like the Windows date time thing. ^^
Questions Regarding Date And Time, Changing System Values
I am preparing an option to prompt user to check the computer time and if necessary update/correct. Has resulted in three questions:
1) what is best way to actually update the system time/date from within VB ?
I am contemplating using a DOS shell command but this is normally a multi-part interaction.
eg. from DOS command prompt
> Date
The current date is: Mon 16/04/2007
Enter the new date: (dd-mm-yyyy)
2) evidently I have a regional setting with dd-mm-yyyy.
Is there a fool-proof way around regional settings without having to query windows (and needing to write further code to do so) ?
3) Within my code I have used a date variant etc to load current system values using now, date, time.
For my GUI input I have collected values as seperate variables, is there a simple way to load values into a date variable defined as variant ?
eg. books say Dim myDate as variant = # 2-April-2007 16:30 #
but is there an option to feed variables directly into a date variant or do I have to make a string ?
eg. I have variables D1,M1,Y1,hh1,mm1,ss1.
myDate = someFunction(D1,M1,Y1,hh1,mm1,ss1)
so that I can then go on and use the date/time VB functions.
Thanks for your help.
Darren
Time Zone And Setting System Time
Hi All,
When we are using SetSystemTime API , how can we adjust the system time with respect to Time Zone?
For example,
I am living Eastern Time ( GMT - 5 ) , When I use the SetSystemTime API, windows calibrates the hour value ( expressed in UTC ) in SYSTEMTIME structure I pass and I get incorrect results.
Thanks all
Dll For System Time (implementing Trial Time Out)
I only want to let someone use my program for 30 days. Is there something I can write in the code that would make that possible? I know that if I do date checking, the user can just set the clock time back on their computer and use the program forever. if it is possible to set a limit, is there someway that I can have the program delete itself after this timeframe?
How Can I Use The Real System Time To Count My Time?
When my app start, I want to count how many seconds it passed. Not only within one day, maybe for a long time count. because I found many "time function" can only count within 24 hrs.
Thanks!
Best Regards,
Kevin Shen
Updating System Time With VB Time...
Hi Everyone,
Just had a quick question. Is it possible to allow someone to update thier system time with the time control in VB?
If so, please let me know how that is possible.
Thanks!
System Time Gets Me Every Time.
Hey guys...
I've never really been that great working with the system time, so now I have a little problem. I have a few variables... they are...
Code:
Dim varDay As Integer
Dim varMonth As Integer
Dim varYear As Integer
' Time variables...
Dim varHour As Integer
Dim varMinute As Integer
How would I assign a number to each of those variables based on the time right now. So for instance, it's September 1, 2002. So varDay = 1, varMonth = 9 and varYear = 2002. The time is 1:01 PM, so varHour = 13 and varMinute = 1.
How could I go about doing this? Thanks!
Get System Time From UTC Time
OK Guys 'n Gals,
Since no one responded to My Last Post
Most likely because of the way I asked the question.
I have the following to convert the UCT date time stamp in the event viewer to the Local system time. However it seems to me that this requires more API calls than should be necessary to accomplish this. Does anyone know of a better method for converting the UTC Date/Time to Local Date/Time?
My Current Code
Code:
Private Declare Function SystemTimeToFileTime Lib "Kernel32" _
(lpSystemTime As SYSTEMTIME, lpFileTime As FILETIME) As Long
Private Declare Function FileTimeToLocalFileTime Lib "Kernel32" _
(lpFileTime As FILETIME, lpLocalFileTime As FILETIME) As Long
Private Declare Function FileTimeToSystemTime Lib "Kernel32" _
(lpFileTime As FILETIME, lpSystemTime As SYSTEMTIME) As Long
Private Declare Function VariantTimeToSystemTime Lib "oleaut32" _
(ByVal vtime As Double, psystime As SYSTEMTIME) As Long
Private Declare Function SystemTimeToVariantTime Lib "oleaut32" _
(psystime As SYSTEMTIME, pvtime As Double) As Long
Public Function DateToLocalDate(ByVal dteTimes As Date) As Date
Dim typSystemTime As SYSTEMTIME
Dim typFileTime As FILETIME
Dim typLocalFileTime As FILETIME
Dim dblReturn As Double
VariantTimeToSystemTime CDbl(dteTimes), typSystemTime
SystemTimeToFileTime typSystemTime, typFileTime
FileTimeToLocalFileTime typFileTime, typLocalFileTime
FileTimeToSystemTime typLocalFileTime, typSystemTime
SystemTimeToVariantTime typSystemTime, dblReturn
DateToLocalDate = dblReturn
End Function
Since this is done all the time within windows I would think there would be a more direct method but I can not seem to figure it out.
How To Convert My GMT Time To U.S.Central Time And Daylight Saving Time
How to convert my GMT date and time to Central Standard and Daylight Saving Time.
For example I have GMT Time as:
02/29/2004 1:00:00 AM
I want as:
02/28/2004 8:00:00 PM
When I give date aswhich is falling under daylight saving time)
04/08/2004 1:00:00 AM
I want to get as 04/07/2004 9:00:00 PM
How to do that and how to determine wheather it is falling under daylight or standard time.
It should not do based on my Computer date and time though. If it is then it is going
to calculate everything based on daylight saving time because right now I'm under daylight
saving time.
I appreciate your help.
Thanks
VM
Timer Time?
I currently have around 10 text boxes all using the same SIXTY lines of code
on _change...they all do the same thing (just updating some labels on the form)..
so would it work to have a timer, and on interval 1 it would run that code, so bascially instantly.....that would mean it would always be updated, and i wouldnt have a bookful of code.....and i doubt it would slow the program or anything...i mean it is runnin every second but its only a small thing.
Anyone Got The Time? My Timer Needs Help
My Time Clock isnt working right...
I have a program I wrote for my son whom we Home school and its a Math test App. Anyway, if I set the time for 3 minutes when the time is up it shows that time was up at 2 minutes 53 seconds or something like this instead of 3 minutes.
I am posting the code... where did I go wrong... Also note wrote this sometime backl... looking at it I can see a lot of areas that need cleaning ... in fact it might fix it just to clean it LOL.
Anyway, so if anything appears redundant its ok cut away
Code:
Private Sub Timer1_Timer()
counter = counter + 1 'we set the counter to count here
Text1.Text = counter
If counter = txtMinutes.Text * 60 Then ' txtMinutes.Text is where we enter the amount of time for Test
Call EndProc ' End of test shut down so to speak
End If
End Sub
Private Sub EndProc()
Timer1.Enabled = False 'stops the timer by disabling it
Dim Isec As Integer
Dim BreakSec As String
Finish = Now
lblFinish.Caption = Finish
elapsed = DateDiff("s", Start, Finish)
Isec = Val(Text1.Text)
BreakSec = Str$(Int(Isec / 60)) & " minutes " & Str$(Isec Mod 60) & " seconds "
Text2.Text = BreakSec
cmdStop.Value = False
End Sub
Private Sub tmrTimer_Timer()
Static intTime
If IsEmpty(intTime) Then intTime = 1
PrgBar1.Value = intTime
If intTime = PrgBar1.Max Then
tmrTimer.Enabled = False
PrgBar1.Visible = False
intTime = 1
PrgBar1.Value = PrgBar1.Min
lblMsg.Caption = "Your Time is Up!!!"
Call EndProc
Else
intTime = intTime + 1
End If
End Sub
vbMarkO
Why Max Time With TIMER Only 10 Min
The Timer object has a max interval 10 min (or ca 66.000 milliseconds)
I need a timer that acts on hour Interval, any idea how I can do that, is there any other Timer object that doesn't count in milliseconds
Thanks VidarJul
Timer Vs Time()
Here is a Loop that uses Timer() to record how long a loop takes.
A second Loop used Time() to track the same loop.
The two loops record sisgnificantly different results.
Anyone care to comment as to why and which is more accurate if either. I realize there is a Timer API I could be using but this is a curiosity.
option Explicit
'
private Sub Command1_Click()
Dim strt as Single, stp as Single, x as Long
strt = time()
Do Until x = 10000000
x = x + 1
Loop
stp = time()
print "time() " & stp - strt
End Sub
'
private Sub Command2_Click()
Dim strt as Single, stp as Single, x as Long
strt = Timer
Do Until x = 10000000
x = x + 1
Loop
stp = Timer
print "Timer " & stp - strt
End Sub
John G
Determining Time From Timer
Is there a good way to determine the actual time in hours min sec from the timer function ( seconds since midnight )
I have a bunch of files with events recorded from the timer (seconds since midnight) and would like to assign an actual time hh:mm:sec to them .
I have been trying to subtract the (timer / 60) from the (timer 60) and multiplying the results by 60... I'm getting a headache.
I figured someone would know a better way
thanks
Simple Timer To Let Me Know When Time Is Up
I'm looking for a simple app that when opened does the following:
a) Checks the time on the computer,
b) counts down and lets me know with a ping or something my time is up. Let's say I want it to let me know 1 minute is up....ping, then let me know another min is up......ping. and STOP in "x" minutes [ say 5 minutes] and place a message on my form "you have used up 5 min". When a button is pushed it starts again.
This is probably very simple, but I have not got experience using timers and would be grateful for this help.
Thank you.
Run Timer And Other Functions At The Same Time
i have a timer and its function is just to create an incremental dots in the status bar. However I am thinking how the codes are running at the SAME time. In another words, as the timer runs, the program is running another codes (for eg loops ) at the same time.Thanks
Regards
Goh
Get Elapsed Time Of A Api Timer
I'm using the API timer: SetTimer.
Question is, how do I check to see how much time has elapsed on any one of the timers that I have started (I have 4 going presently)?
Timer - Changing Time Value
Hopefully this should be an easy one...
I have an array of values...
I want to use the first value in the array to set how long i want the timer to run for....then, when the timer triggers, it runs again but with the 2nd value in the array....when it triggers, the 3rd value in the array and so on...
How do i do this?
The array is of unknown length!
Matt
Timer Count Down A Time By 1 Sec?
hey, lets say i had this for a timeleft, 15:20
that would be 15 min and 20 sec
how would i make a timer make that go down by 1 sec every second? and keeping it in that format?
thanx
Exact Time On A Timer
hi!
I wanted to know if there's code I can put into a timer (or anything else), that will always display the current time (minutes and seconds). I found a formula that works on my computer, but if I would run it on a 486, it would be much too slow. Any ideas?
------------------
Regards,
Alexander McAndrew
VB Zone
http://gsenterprise.server101.com
Exact Time On A Timer
hi!
I wanted to know if there's code I can put into a timer (or anything else), that will always display the current time (minutes and seconds). I found a formula that works on my computer, but if I would run it on a 486, it would be much too slow. Any ideas?
------------------
Regards,
Alexander McAndrew
VB Zone
http://gsenterprise.server101.com
System Date And System Time
(on click of command button) how do i save the text in a textbox to a .txt file with "Log - " + system date + " - " + system time ? into the application's folder...
Using A Timer Or (Time Of Day) To Set Conditional Format
This one is easy...but not for me...
I would like to set a coditional format based on the time of day
Setup: I have TimeStamped a cell and would like to format either that cell or another based on the time in the time stamped cell + a set interval of time.
Something like this:
Code:
if ("Now") < Range("A1")+30 minutes then ConditionalFormat = Green
if ("Now") > Range("A1")+30 minutes And ("Now") < Range("A1")+90 minutes then ConditionalFormat = Yellow
if ("Now") > Range("A1")+90 minutes then ConditionalFormat = Red
(Not actual code, I know...but it should be...I mean even I can write that!)
Anyway..Am I even close?
Thanks As always
RT91
Timer Woes, Time For An Interrupt?
I am writing a program that has a scrolling message & slideshow and I developed these programs separately and they work together fine when running as two separate processes.
Now I'm bringing them together into one application and the problem is while the slideshow opens a window or loads pictures or does anything substancial there is a major pause in the scroller. This just can't happen
I can't simply add a "DoEvents" everywhere to counteract this problem either. Some processing, for example "LoadPicture", "SavePicture" etc. can't have DoEvents during that procedure. Plus running a DoEvents during particular functions causes all sorts of mayhem.
Is there any way I can trap a hardware timer or get some low level interrupt happening so the processor *must* process events for the scroller? In the old DOS days you would setup a hardware interrupt, is there something like this for VB? ... and any ideas & sample code would be greatly appreciated
Creating A Timer Control At Run-Time
Ok, this may sound really silly, but I have an unknown number of aspects to control via Timer(s) at run-time.
I don't expect more than say 5 or 10, so I could place up to 10 Timer Controls on a Form and just make use of them as needed (keeping track of which one(s) have been used so far...)
But another thought is to simply add Timer Control(s) at Run-Time, as needed. My form could start with zero Timers and then I'd add them if/when I needed...
Does anyone have a clue as to how to do that?
I thank you all in advance...
Mike
Time/date Timer Question
Hey i just wanted to ask if there is another way to look at a value at a specified timerange like a timer does. i can use a timer nut i just have to check the value once a day. i have to start a function when the first day of a month arrives. Is there a built in control to use or how can i work around? I could live with the timer and set it to MAX interval... but i hope there is a smarter way.
Thanks
Bye
Timer/OptionButton Crashing 100% Of Time. Help?
I want the two option buttons to flash but this code causes VB to freeze up and crash 100% of the time. Any help? Thanks.
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Option1
Dim i As Integer
'
Option1.value= True
For i = 1 To 6
Sleep 500
Option2.Value = True
Sleep 500
Option1.Value = True
Next i
Option1.value= False
End Sub
I have also placed this in my Timer1 sub, but it too crashes. By crash, I mean that the two option buttons do flash from one button to the other, but the form is transparent and the flashing never stops. Clicking on X or stop does nothing. The "Program is not responding" comes up and I loss everything.
How To Show Time Elapsed Using Vb Timer?
Hello, I'm trying to make a app for a sports, that will show me the "time elapsed" using vb timer or time() function as Hour : Min : Second format. Time must start as 00:00:00. and again 00:00:00 when reset button clicked.
I searched whole internet for this, i couldn't find any proper answer for this.
I am a newbie, Please help.
Countdown Timer Time Format?
Hey guys, making a countdown timer. I've got a textbox where i enter a time and a label which displays the time. How can i program these to show it in time format
Heres my code so far but it just counts down a number in seconds. I want it to countdown in hours, minutes and seconds.
VB Code:
Private Sub Timer1_Timer() lblCountdown.Caption = Countdown If Countdown = 0 Then Timer1.Enabled = False Exit Sub End If Countdown = Countdown - 1 End Sub Private Sub cmdStart_Click() If IsNumeric(text1.text) Then Countdown = CInt(text1.text) Timer1.Interval = 1000 Timer1.Enabled = True Call Timer1_Timer End If
thanks
Countdown Timer / Time Limit
how can i make a time limit thing
so i have a timer and i want it to countdown and show that limit counting doen on the form and when it gets to 0 the games finishes and thay lose
Waiting Time, Without Timer Control
I have run into a situation where I need vb to wait 20 minutes or so before executing a command. The timer control only allows for 1 minute. Can someone give me an idea on how to go about this.
Thanks again for all the help.
Ed
Stop Timer API In Desing Time
Hi
I'm problem , I put a API timer that trigger, but when the developer is testing and forget of kill the process the windows return GPF, How I resolve my problem
thank you in advance
Time Event Not Using Timer ObjecT
I'm sure this has been answered before but,
Is there some way to time events other than using the Timer object, and if so, which uses less resources - the Timer object or the other way.
Thanks,
Dave
P.S. I did search for an other post like this, but they all didn't quite seem relevant to what I'm trying to do.
Internet Duration Time Timer
I am trying to make a program that starts a stopwatch like timer when you connect to the internet and stops the timer when you disconnect. Then next time you connect it adds to the time the stopwatch was at.
Why Does The Timer Not Consistent With The Real Time?
I have a strange question of vb timer. The below is an easy program to show that.
On front Panel there's two time show. One is from the real time (Label1.Caption=Time), the other is calculated from Timer1(interval=1000).
option Explicit
Dim i as Long
private Sub Form_Load()
Timer1.Enabled = true
Timer1.Interval = 1000
End Sub
private Sub Timer1_Timer()
i = i + 1
Label2.Caption = Format(i / 3600, "#0.0000")
Label1.Caption = time
End Sub
Write down the initial time. After running 14 hours, the time value from Timer1 only show 13.38 hrs. Label2 suppose should show 14.00 hrs.
I don't know why. Right now I wrote test automation program depend on Timer, is the vb not suitable for this kind of program?
Thank you!
Best Regards,
Kevin Shen
Quick Time And IE Questions
Hello...
Can anyone tell my how to quick and easily return "the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)."
Also, how do you open a new internet explorer window in a specific size, no address bar etc
I would really appreciate it
Thanks, Lee
Keyboard And Time Questions
Hello guys
this forum is helping me alot to program my executable
i just want to thank you all
How can i check if a key is pressed (with or without the program in focus?)
How can i use timers?
how can i add a value to a string ?
such as mystring += "file"
mystring += "hlp"
mystring = "filehlp"
??
thank you very much
Few Questions ( First Time On This Forums )
Hi guys first time I'm posting here, so excuse me if I'm posting in wrong section.
I'm owner of www.BADHQ.com ( Advanced BF2 Clan Tools ) I've been working on small project, ( BF2 Bug fixer ) Now I never worked with VB before, but I have worked with similar programs OK here is my question
Lets say I wanted to change settings in "dxdiag" control panel Like this
Now I want to add this feature in VB so people can change it in VB Rather then them, doing it long way I.E " run > type in dxdiag> go to sound tab" and so on and so on
Reason I want this in VB it's because sorts out VOIP in BF2 if its set to right settings. so far thats about it
Does anyone know how can I add just Hardware Sound Acceleration Level In VB? ( like pic above just that bottom section of the sound I don't need nothing ells )
Or is there a norther way to GET VB to change that level in dxdiag from VB it self?
Sorry for my bad English. All coments are welcome, and sorry if I posted this in wrong section.
Peace Boris
P.S this is my VB layout so far
( I made the images for it )
How To Pick Different Questions Every Time
Hi,
I want to pick different records from the database every time when user open our site. these records are questions which are stored in the database.
Could any body tell me how to do so.
Thank You,
System Time
Could someone please show me how to get a text box to update the time every second. This is my code but it does not update, it only shows the time as of loading the form.
Code:
Timetxt.Text = Time
Getting System Time To Use In VB App
Hey all,
How can I get the system time to use in an application. Also once I get the system time how can I convert it to 24 hour time??
Thanks.
Cam.
System Time
How do I call the system time and date. Is it just Date?
Thanks,
Animaul
System Time
i would like to know how you would go about getting the system time.
System Time
I'm trying to insert the time from the system tray with no luck.
I'm inserting directly from the status bar like:
Insert into Employee bla bla bla Values( ' Statusbar1.Panel(1) ') ... ect.
|