Put a picture box on your form, and a timer with interval of 1000
Leave default names
VB Code:
Public Sub ShowAnalogTime(ByVal MyTime As Date, Pic As PictureBox) Dim H As Single, M As Single, S As Single Const HPI As Double = 1.5707963267949 ' (4 * Atn(1)) / 2 Const PI2 As Double = 6.28318530717959 ' (4 * Atn(1)) * 2 H = (Hour(MyTime) Mod 12) / 12# M = Minute(MyTime) / 60# S = Second(MyTime) / 60# Pic.Scale (-1.1, -1.1)-(1.1, 1.1) Pic.DrawWidth = 2 Pic.Cls Pic.Circle (0, 0), 1, RGB(128, 128, 128) Pic.Line (0, 0)-(0.5 * Cos(PI2 * H - HPI), 0.5 * Sin(PI2 * H - HPI)), RGB(0, 0, 128) Pic.Line (0, 0)-(0.8 * Cos(PI2 * M - HPI), 0.8 * Sin(PI2 * M - HPI)), RGB(128, 128, 255) Pic.Line (0, 0)-(Cos(PI2 * S - HPI), Sin(PI2 * S - HPI)), RGB(255, 255, 255) End Sub Private Sub Timer1_Timer() ShowAnalogTime Time, Picture1 End Sub




Reply With Quote