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

#1 tel0r   User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • 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

Private Sub Form_Load()
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   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

#3 jakerman999   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

#4 OMI   User is offline

  • New D.I.C Head

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

Re: Analog Clock

Posted 10 October 2008 - 02:56 PM

Thank u for lending me this code
Was This Post Helpful? 0
  • +
  • -

#5 arjay_cabingas   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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.......
Was This Post Helpful? 0
  • +
  • -

#6 Vineeth k   User is offline

  • D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • 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..
Was This Post Helpful? 0
  • +
  • -

#7 arj1991   User is offline

  • New D.I.C Head

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

Re: Analog Clock

Posted 26 July 2010 - 06:53 AM

at run time nothing is visibel
Was This Post Helpful? 0
  • +
  • -

#8 Mok'Nathal   User is offline

  • New D.I.C Head

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

Re: Analog Clock

Posted 23 February 2011 - 02:27 AM

Thanks
Was This Post Helpful? 0
  • +
  • -

#9 KevinLadan   User is offline

  • New D.I.C Head

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

Re: Analog Clock

Posted 19 May 2011 - 02:33 AM

this is cool..
Was This Post Helpful? 0
  • +
  • -

#10 Dialga   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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
Was This Post Helpful? 0
  • +
  • -

#11 onemig   User is offline

  • New D.I.C Head

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

Re: Analog Clock

Posted 11 January 2012 - 01:07 PM

nice bro it coll stuffffff......
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1