手机版

VB做电子报时钟(9)

发布时间:2021-06-06   来源:未知    
字号:

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

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文档下载到电脑,方便复制、编辑、收藏和打印
×
二维码
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)