# Analog Clock

Page 1 of 1

## 10 Replies - 4233 Views - Last Post: 11 January 2012 - 01:07 PM

### #1 tel0r

Reputation: 1
• Posts: 27
• Joined: 22-February 05

# Analog Clock

Posted 19 June 2005 - 01:45 AM

Description: c&p code, add timer control (Timer1) to the form with an Interval of 1000, and Enabled set to TrueNice, easy analog clock code.
```Option Explicit
Const T As Double = 57.29577951

Me.Height = 2048
Me.Width = 2048
End Sub

Private Sub Form_Resize()
Me.ScaleHeight = 100
Me.ScaleWidth = 100
End Sub

Private Sub Timer1_Timer()
Dim H As Long, M As Long, S As Long                     'time units
Dim Hd As Double, Md As Double, Sd As Double            'Degrees
Dim Hr As Double, Mr As Double, Sr As Double            'Radians

Me.Cls
H = Hour(Time): M = Minute(Time): S = Second(Time)

If H >= 12 Then H = H - 12

Hd = H * 30
Hd = Hd + M / 2
Md = M * 6
Sd = S * 6

Hd = Hd - 90: Md = Md - 90: Sd = Sd - 90

If Hd < 0 Then Hd = Hd + 360
If Md < 0 Then Md = Md + 360
If Sd < 0 Then Sd = Sd + 360

Hr = Hd / T: Mr = Md / T: Sr = Sd / T

Line (50, 50)-(Me.ScaleHeight / 2 + ((Me.ScaleHeight / 2) * 0.5 * Cos(Hr)), Me.ScaleWidth / 2 + ((Me.ScaleHeight / 2) * 0.5 * Sin(Hr))), vbBlack
Line (50, 50)-(Me.ScaleHeight / 2 + ((Me.ScaleHeight / 2) * 0.6 * Cos(Mr)), Me.ScaleWidth / 2 + ((Me.ScaleHeight / 2) * 0.6 * Sin(Mr))), vbBlue
Line (50, 50)-(Me.ScaleHeight / 2 + ((Me.ScaleHeight / 2) * 0.7 * Cos(Sr)), Me.ScaleWidth / 2 + ((Me.ScaleHeight / 2) * 0.7 * Sin(Sr))), vbRed

End Sub

```

Is This A Good Question/Topic? 0

## Replies To: Analog Clock

### #2 bonzo0

Reputation: 0
• Posts: 1
• Joined: 09-July 08

## Re: Analog Clock

Posted 09 July 2008 - 05:06 AM

there are no digits to represent 1 to 12. only the hands are moving.

### #3 jakerman999

Reputation: 1
• Posts: 17
• Joined: 07-August 08

## Re: Analog Clock

Posted 08 August 2008 - 12:15 PM

disable the max button and min button, then add the following code. Dim strTime As String Dim strH As String, strM As String, strS As String strH = H strM = M strS = S If H < 10 Then strH = "0" & H If M < 10 Then strM = "0" & M If S < 10 Then strS = "0" & S strTime = strH & ":" & strM & ":" & strS Form1.Caption = strTime also, try placing your dim statements in the general section instead of the timer control, otherwise you use to much ram.

### #4 OMI

Reputation: 0
• Posts: 0
• Joined: 10-October 08

## Re: Analog Clock

Posted 10 October 2008 - 02:56 PM

Thank u for lending me this code

### #5 arjay_cabingas

Reputation: 0
• Posts: 0
• Joined: 25-November 08

## Re: Analog Clock

Posted 25 November 2008 - 03:31 AM

ohhh...this site are so very helpful because you can get more of codes as you like...... thank......guysss.....dont worry friends i would help you if i knew.......

### #6 Vineeth k

Reputation: 2
• Posts: 50
• Joined: 25-October 09

## Re: Analog Clock

Posted 25 October 2009 - 09:54 PM

Thanks for the code really i am looking for this code.Thanks for sharing this..

### #7 arj1991

Reputation: 0
• Posts: 0
• Joined: 26-July 10

## Re: Analog Clock

Posted 26 July 2010 - 06:53 AM

at run time nothing is visibel

### #8 Mok'Nathal

Reputation: 0
• Posts: 5
• Joined: 23-February 11

## Re: Analog Clock

Posted 23 February 2011 - 02:27 AM

Thanks

Reputation: 0
• Posts: 0
• Joined: 14-May 11

## Re: Analog Clock

Posted 19 May 2011 - 02:33 AM

this is cool..

### #10 Dialga

Reputation: 0
• Posts: 49
• Joined: 13-May 11

## Re: Analog Clock

Posted 09 June 2011 - 06:56 PM

because you have to set the timer interval to 1000 to see the hands

### #11 onemig

Reputation: 0
• Posts: 3
• Joined: 11-January 12

## Re: Analog Clock

Posted 11 January 2012 - 01:07 PM

nice bro it coll stuffffff......

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }