VB做电子报时钟(9)

时间:2025-04-05

模拟电子钟 带语音报时功能

Private Function huamiao ( a As Integer )

'用同背景相同的颜色,在前一次的位置上,从新画直线,抹除前一次画的线 x =(1–Sin((a+1)/60*2*3.1415926))*(Form1.ScaleHeight/2–200)+200 y =(1–Cos((a+1)/60*2*3.1415926))*(Form1.ScaleHeight/2–200)+200

Line(Form1.ScaleHeight/2,Form1.ScaleHeight/2)-(x,y),QBColor ( 7 ) '然后开始画後一秒的线

x =(1–Sin(a/60 * 2 * 3.1415926 ) ) * (Form1.ScaleHeight/2–200)+200 y =(1–Cos(a/60 * 2 * 3.1415926 ) ) * (Form1.ScaleHeight/2–200)+200 Line(Form1.ScaleHeight/2,Form1.ScaleHeight/2)-(x,y),QBColor ( 1 ) huamiao = a - 1 End Function

Private Sub Timer1 _ Timer ( ) mz =Second(time)

mz =60–mz ‘因为三角函数中,角度的变化方向,正好与钟表的方向相反,

‘所以60减去就相当于将角度变为负值,也就是说,和原来的角度增长方向正好相反,与钟表的增长方向相同。 mz = huamiao ( mz ) End Sub

下面是运行效果:

好了,现在我们可以加上,分针和时针了.下面是源代码和运行结果:

' = = = = = = = = = = = = = = = = = = = = = = ' 以下语句能画出表盘 ‘ 六十个点表示六十个刻度,

' = = = = = = = = = = = = = = = = = = = = = = Private Sub huayuan ( ) Dim x As Double Dim y As Double

For i = 0 To 60

x = ( 1 – Sin ( i / 60 * 2 * 3.1415926 ) ) * ( Form1.ScaleHeight / 2 – 100 ) + 100 y = ( 1 – Cos ( i / 60 * 2 * 3.1415926 ) ) * ( Form1.ScaleHeight / 2 – 100 ) + 100 PSet ( x , y ) , QBColor ( 12 ) Next i

End Sub

‘ = = = = = = = = = = = = = = = = = = = = = = = = = = ‘下面代码作用是画出时针走的路线 ‘时针是12个刻度,表示是12个钟点

‘ = = = = = = = = = = = = = = = = = = = = = = = = = = Private Function xianshishi ( a As Integer ) '抹除前一次画的线

VB做电子报时钟(9).doc 将本文的Word文档下载到电脑

精彩图片

热门精选

大家正在看

× 游客快捷下载通道(下载后可以自由复制和排版)

限时特价:7 元/份 原价:20元

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219