pedie
Well-known Member
- Joined
- Apr 28, 2010
- Messages
- 3,875

Please help...any help will be appriciated:
Sub Updateclok()<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com




' Updates the clock that's visible<o


Dim Clock As Chart<o


Set Clock = ThisWorkbook.Sheets("Sheet1").ChartObjects("ClockChart").Chart<o


<o


If Clock.Parent.Visible Then<o


' ANALOG CLOCK<o


Const PI As Double = 3.14159265358979<o


Dim CurrentSeries As Series<o


Dim s As Series<o


Dim x(1 To 2) As Variant<o


Dim v(1 To 2) As Variant<o


<o


' Hour hand<o


Set CurrentSeries = Clock.SeriesCollection("HourHand")<o


x(1) = 0<o


x(2) = 0.5 * Sin((Hour(Time) + (Minute(Time) / 60)) * (2 * PI / 12))<o


v(1) = 0<o


v(2) = 0.5 * Cos((Hour(Time) + (Minute(Time) / 60)) * (2 * PI / 12))<o


CurrentSeries.XValues = x<o


CurrentSeries.Values = v<o


<o


' Minute hand<o


Set CurrentSeries = Clock.SeriesCollection("MinuteHand")<o


x(1) = 0<o


x(2) = 0.8 * Sin((Minute(Time) + (Second(Time) / 60)) * (2 * PI / 60))<o


v(1) = 0<o


v(2) = 0.8 * Cos((Minute(Time) + (Second(Time) / 60)) * (2 * PI / 60))<o


CurrentSeries.XValues = x<o


CurrentSeries.Values = v<o


<o


' Second hand<o


Set CurrentSeries = Clock.SeriesCollection("SecondHand")<o


x(1) = 0<o


x(2) = 0.85 * Sin(Second(Time) * (2 * PI / 60))<o


v(1) = 0<o


v(2) = 0.85 * Cos(Second(Time) * (2 * PI / 60))<o


CurrentSeries.XValues = x<o


CurrentSeries.Values = v<o


Else<o


' DIGITAL CLOCK<o


ThisWorkbook.Sheets("Sheet1").Range("DigitalClock").Value = CDbl(Time)<o


End If<o


<o


' Set up the next event one second from now<o


NextTick = Now + TimeValue("00:00:01")<o


Application.OnTime NextTick, "Updateclok"<o


<o

