PrivateSubForm_Load()
Timer1.Interval=100
Width=4000
Height=4000
Left=Screen.Width2-2000
Top=(Screen.Height-Height)2
EndSub
PrivateSubForm_Resize()
DimI,Angle
StaticflagAsBoolean
Ifflag=FalseThen
flag=True
ForI=0To14
'畫出表盤12個點和時、分、秒共15個Line
IfI>0ThenLoadLine1(I)
Line1(I).Visible=True
Line1(I).BorderWidth=5
Line1(I).BorderColor=RGB(200,100,60)'設置LINE的精細和顏色
NextI
EndIf
ForI=0To14
Scale(-1,1)-(1,-1)
Angle=I*2*Atn(1)/3
Line1(I).X1=0.9*Cos(Angle)
Line1(I).Y1=0.9*Sin(Angle)
Line1(I).X2=Cos(Angle)
Line1(I).Y2=Sin(Angle)
NextI
EndSub
PrivateSubTimer1_Timer()
ConstHH=0
ConstMH=13
ConstSH=14
DimAngle
StaticLS
IfSecond(Now)=LSThenExitSub
LS=Second(Now)
Angle=0.5236*(15-(Hour(Now) Minute(Now)/60))'設置時針
Line1(HH).X1=0
Line1(HH).Y1=0
Line1(HH).X2=0.3*Cos(Angle)
Line1(HH).Y2=0.3*Sin(Angle)
Angle=0.1047*(75-(Minute(Now) Second(Now)/60))'設置分針
Line1(MH).X1=0
Line1(MH).Y1=0
Line1(MH).X2=0.7*Cos(Angle)
Line1(MH).Y2=0.7*Sin(Angle)
Angle=0.5236*(75-Second(Now)/5)'設置秒針
Line1(SH).X1=0
Line1(SH).Y1=0
Line1(SH).X2=0.8*Cos(Angle)
Line1(SH).Y2=0.8*Sin(Angle)
Form1.Caption=Str(Now())'窗口顯示精確的日期和數字化的時間
EndSub
(3)程序的編譯和執行
點擊VB“運行”菜單中的“啟動”或“全面編譯”命令,即可對程序編譯並運行!
注:上述程序在中文Windows98和VB5.0中文企業版下調試通過。