|
-
Jul 17th, 2000, 02:31 PM
#1
Thread Starter
Hyperactive Member
Once my program starts, how would I get it to grab the time and have its own clock. I can do this however only be refreshing the label1.caption every second. There has to be a better method, any ideas?
-RaY
VB .Net 2010 (Ultimate)
-
Jul 17th, 2000, 03:07 PM
#2
Fanatic Member
hi,
create a timer, set the interval to 1000 and make sure that it is enabled, then put the following code in it
label1.caption = time
hope this helps
Merlin ?
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Jul 17th, 2000, 03:19 PM
#3
Hyperactive Member
How frequently do you want to update?
zmerlinz has told you how most of us would probably do the job. Having a timer set to 1000 milliseconds is not much of a burden on the system if that is what you are worried about.
When he mentioned "put the following code in it", of course, he means ion the Timer1_Timer event.
Regards
Paul Lewis
-
Jul 17th, 2000, 03:29 PM
#4
Addicted Member
If you just want a clock. Add a status bar control and set one the panel to be a clock.

Glenn D
Development/Analyst
-
Jul 17th, 2000, 03:44 PM
#5
Originally posted by PaulLewis
How frequently do you want to update?
The most you can update the standard clock is by 1 second. You would just be repeating many times if you went lower.
-
Jul 18th, 2000, 04:36 AM
#6
transcendental analytic
As timer control is a very inaccurate timer (up to 53 ms), you may notice it won't update each second if you put interval to 1000ms. you may have to update it each 100 ms if you want to have a accurate looking clock or you would have to use a loop with a timer method or use settimer api
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 18th, 2000, 08:26 AM
#7
I don't think API is necessary for making a simple clock on the program. If you want it really accurate, just set the Timer's interval to 1.
-
Jul 18th, 2000, 08:47 AM
#8
PowerPoster
Long time ago when I still used timers to make clocks I setted it's interval to 200 or 300 so it nearly updates every second. To prevent flickering check if the label already contains the time:
Code:
Private Sub Timer1_Timer()
If Not Label1.Caption = Time Then: Label1.Caption = Time
End Sub
-
Jul 18th, 2000, 08:49 AM
#9
Fanatic Member
' only refresh label when time has changed
' timer at intervals of whatever 100ms?
timer1_timer()
localtimer = format(datetime,"h:mm:ss")
if localtimer <> lasttimer then
label1.caption = localtimer
lasttimer = localtimer
end if
exit sub
Kurt Simons
[I know I'm a hack but my clients don't!]
-
Jul 18th, 2000, 05:33 PM
#10
transcendental analytic
If you want it really accurate, just set the Timer's interval to 1.
Just by setting it to 1 you won't get it accurate less than 53 millisecond and the event will also fire less than 20 times a second
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 18th, 2000, 05:44 PM
#11
That is a good thing, kedaman, because we are only concered with the accuracy of the second, not the milliseconds.
-
Jul 18th, 2000, 06:26 PM
#12
transcendental analytic
If there's a visual purpose, you want to have the time to be updated using an event which won't be accurate if you use timer control, therefore by setting a small interval you will update it as accurate as possible.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 18th, 2000, 06:57 PM
#13
Yes, but that's what we want, as long as there is no flickering involved.
-
Jul 18th, 2000, 07:40 PM
#14
Fanatic Member
Clash of the Titans (GURU's) 
What's this about the staus bar being set to clock? I've never heard of that!! Thanks's Glen. Think it's time to have a play...
Paul
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
Jul 19th, 2000, 08:38 AM
#15
Try something like this.
Code:
Private Sub Timer1_Timer()
StatusBar1.Panels(1).Text = Time
End Sub
-
Jul 19th, 2000, 08:43 AM
#16
Addicted Member
Unless you require a clock with seconds you don't need to use a timer with the status bar. Just set the style property of the panel to sbrTime.

Glenn D
Development/Analyst
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|