473,508 Members | 2,236 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6487
<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
6685
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
2232
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
408
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
47574
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
3958
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
8881
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
3945
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
4066
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
6923
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"
0
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7331
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7391
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7501
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3204
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.