473,237 Members | 1,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,237 software developers and data experts.

Analogue Clock

ray
Ah well, it had to happen.

Create a new form, minimum size 14cm by 14cm.
Anywhere on the form, place 3 lines of any length called scrLineSecond,
scrLineMinute and scrLineHour.

Set the form's TimerInterval to 1000.

In the OnTimer event, past the following:

Private Sub Form_Timer()
Call calcClockHands("Second", Second(Now()))
Call calcClockHands("Minute", Minute(Now()))
Call calcClockHands("Hour", Hour(Now()))

End Sub

Then paste in the following sub:
NOTE: The calculation (7 * 567) is 7cm * 567 twips per centimetre and
marks the centre of the form. If you work in other units you will have
to change them accordingly. 3750 is the length of the secondhand in
twips, 3500 the length of the minute hand, and 2750 the length of the
hour hand. Again, change these to suit yourself.

Private Sub calcClockHands(parHand As String, x As Integer)
Const pi = 3.142857
Const nCentreLeft = (7 * 567), nCentreUp = (7 * 567)
' This code copyright Ray Corbin 2006
' Blue Bridge Pty Ltd, Sydney Australia ra*@aic.net.au
' Use wherever provided you include this accreditation.
Dim nWidth As Single, nHeight As Single
On Error GoTo CH_Err

Select Case parHand
Case "Second"
nWidth = 3750 * Sin(84 * pi * x)
nHeight = 3750 * Cos(84 * pi * x)
Case "Minute"
nWidth = 3500 * Sin(84 * pi * x)
nHeight = 3500 * Cos(84 * pi * x)
Case "Hour"
nWidth = 2750 * Sin(412 * pi * x)
nHeight = 2750 * Cos(412 * pi * x)
End Select

Me("scrLine" & parHand).LineSlant = (Abs(nWidth * nHeight) =
(nWidth * nHeight))
Me("scrLine" & parHand).Width = Abs(nWidth)
Me("scrLine" & parHand).Height = Abs(nHeight)
If nWidth > 0 Then
Me("scrLine" & parHand).Left = nCentreLeft
Else
Me("scrLine" & parHand).Left = nCentreLeft + nWidth
End If
If nHeight > 0 Then
Me("scrLine" & parHand).Top = nCentreUp - nHeight
Else
Me("scrLine" & parHand).Top = nCentreUp
End If
CH_Exit:
Exit Sub
CH_Err:
MsgBox Err.Description
Resume CH_Exit
End Sub
Tick Tock folks,

Ray

May 4 '06 #1
7 6462
<ra*@aic.net.au> wrote in message
news:11*********************@i40g2000cwc.googlegro ups.com...
Ah well, it had to happen.


A truly ingenious piece of coding, but what possible use do you see this
having?

Regards,
Keith.
www.keithwilby.com
May 4 '06 #2
<ra*@aic.net.au> wrote in message
news:11*********************@i40g2000cwc.googlegro ups.com...
Const pi = 3.142857


That's some funny pie you are feeding Access. It'll get indigestion! :)

Matt
May 4 '06 #3
ray
Keith, I appreciate the 'ingenious' label! I must confess that I
originally wanted a second hand ticking around a tiny clockface in the
bottom corner of a form, but really it was just a bit of fun. Mind you,
there may be people who require analogue displays of something other
than a clock. This could be easily adapted to show a gauge.

I adapted it yesterday by removing the code from TimerEvent. I took out
the Hour, Minute, Second functions and substituted integer values
looping through 1-12 and 1-60 that ran the clock as fast as it could. I
was quite surprised at how fast it whizzed around!

Incidentally, though, I often find that clients look on Access as a bit
of a 'toy' database, slow and small. It can be displays like this,
paradoxically enough, that stop them as they walk past (this happened a
lot over the last few days with the hands on my clockface spinning
around like a mad thing) and they say "I didn't know Access could do
stuff like that." It gives me a chance to spruik the environment up a
bit, and extend their thinking.

Matt, yes the pi value is a bit berserk!! I didn't look it up at the
time, just tossed it in from memory.

Thanks for your interest folks,

Ray

May 5 '06 #4
Rog
Great stuff, Ray. Thanks for sharing this. It looks great if you give
the three lines different colors.

BTW I think there's a typo in the line
Me("scrLine" & parHand).LineSlant = (Abs(nWidth * nHeight) =
(nWidth * nHeight))
The second = should be a +.

Rog

May 8 '06 #5
"Rog" <de********@state.gov> wrote in
news:11**********************@y43g2000cwc.googlegr oups.com:
Great stuff, Ray. Thanks for sharing this. It looks great if
you give the three lines different colors.

BTW I think there's a typo in the line
Me("scrLine" & parHand).LineSlant = (Abs(nWidth * nHeight)
=
(nWidth * nHeight))
The second = should be a +.

Rog

I think not.

The LineSlant property uses the following settings.

Setting Visual Basic Description
\ False (Default) Upper left to lower right
/ True Upper right to lower left

(Abs(nWidth * nHeight) = (nWidth * nHeight))
returns true or false. It's an absolutely brilliant bit of code.

--
Bob Quintal

PA is y I've altered my email address.
May 8 '06 #6
Rog
I see, you're right. Sorry, my mistake.

Roger

May 10 '06 #7
"Rog" <de********@state.gov> wrote in news:1147178624.065097.201350
@i39g2000cwa.googlegroups.com:
I see, you're right. Sorry, my mistake.

Roger

No need to be sorry.
--
Bob Quintal

PA is y I've altered my email address.
May 10 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: James Harriman | last post by:
Hi, I need to be able to measure a time interval in milliseconds on a windows machine. I have tried using time.clock() but it appears to measure time in seconds...Is there a way to measure time...
9
by: Gino Elloso - Philippines | last post by:
Hello, I made a webpage ( @ Geocities Free Webpages ) that contains a mousetrail clock script. I simply copied the script ( including all html tags ) exactly as it was from a source webpage (...
0
by: Peger, Daniel H. | last post by:
Hi, I'm having a slight problem with the precision of the standard c++ clock function as it is defined in time.h . On my system the shortest meassurable time period is 0.01 seconds, but for my...
33
by: Pushkar Pradhan | last post by:
I'm using clock() to time parts of my code e.g. clk1 = clock(); /* code */ clk2 = clock(); /* calculate time in secs */ ...... clk1 = clock(); /* code */ clk2 = clock();
1
by: BlackTiger | last post by:
How to create analogue of Delphi's 'DataModule'? DataModule is non-visual form, which contains connections to DB, queries, tables, field definitions and relations between tables. All this...
7
by: Oleg Subachev | last post by:
What is C#'s analogue of Delphi's TAction ? If there is no one, how to implement the same functionality > Oleg Subachev
54
by: CoreyWhite | last post by:
The following experiment is a demonstration of TIME TRAVEL. When writing this program, and testing it out I found that sometimes the program would engage itself in time travel but other times it...
12
by: cenktarhancenk | last post by:
is there a way to display a ticking clock in a web page using javascript? but not in a textbox, rather as text that i can change the style, font etc. cenk tarhan
5
by: none | last post by:
Hello, can you help? if I include: #include <time.h> and run the code: clock_t t = clock(); cout << "t is " << t << endl; I get (seemingly randomly) "t is 0" or "t is 10000"
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.