ENGLISH 意见建议 网站地图 网站帮助
广泛智力汇聚   高效成果传播   先进机制培育
联盟首页  |  协同开发  |  开放源码库  |  安全告警  |  开源导航  |  文档中心  |  服务支持  |  共创论坛  |  关于联盟


注册会员 网站帮助
    您的位置 »
    今天是: 2010年11月22日    
项目搜索

完全匹配   
开源软件
软件分类表
新发布软件
其它网站镜像
代码片断
协同开发
文档
论坛
寻求协助
热点项目
站点状态
编译工厂

联系我们
关于联盟

代码片段库:
查看代码片段

浏览 | 提交新的代码片段 | 创建代码包

Display a clock

类型:
Sample Code (HOWTO)
类别:
Games
许可证:
GNU General Public License
语言:
Visual Basic
 
描述:
Copy the declarations and code below and paste directly into your VB project.

该代码片段的版本系列:

片段ID 下载版本 提交时间 提交人 删除
48311.02003-11-24 23:15cbd001

点击"下载版本"来下载该代码片段.


最新版本的代码片段: 1.0


You will need a label (name = label1) somewhere near the bottom and a timer control (name = timer1, interval = 100, enabled = true).

This uses trigonometry, to calculate where the hands should be.

In Declarations:
Option Explicit
Const pi = 3.141592654
Dim MyTime As String
Dim sec As Integer, hr As Integer, Min As Integer
Dim X As Integer, Y As Integer
Dim x1 As Integer, y1 As Integer
Dim xsold As Integer, ysold As Integer
Dim xmold As Integer, ymold As Integer
Dim xhold As Integer, yhold As Integer
Dim Rad
Dim a As Integer
In Form_Load:
xsold = x1 ' This is the old x for the seconds
ysold = y1 ' likewise this is for the mins
xmold = x1
ymold = y1
xhold = x1
yhold = y1
In timer1_Timer()

Dim c1, c2, c3 ' Variant since no As
c1 = RGB(255, 255, 0)
c2 = RGB(0, 0, 255)
c3 = RGB(255, 0, 0)
label1.Caption = Time$
MyTime = Time$
sec = Val(Right(MyTime, 2))
Min = Val(Mid(MyTime, 4, 2))
hr = Val(Left(MyTime, 2))
If hr > 12 Then hr = hr - 12

Call runtime(sec, c1, 5)
If Int(a / 5) = (a / 5) Then Call runtime(Min, c2, 4)

If a = 0 Then Call runtime(hr, c3, 2)

a = a + 1
If a = 29 Then a = 0

Now make this procedure:
Public Sub runtime(value As Variant, colour As Variant, i As Integer)

Circle (x1, y1), 550, RGB(255, 255, 255)
If i = 2 Then
Rad = (30 * value) * (pi / 180)
Else
Rad = (6 * value) * (pi / 180)
End If
X = x1 + (i * 100 * (Sin(Rad)))
Y = y1 - (i * 100 * (Cos(Rad)))
Select Case i
Case 5
frmClock.Line (x1, y1)-(xsold, ysold), RGB(0, 0, 0)
frmClock.Line (x1, y1)-(X, Y), colour
xsold = X
ysold = Y
Case 4
frmClock.Line (x1, y1)-(xmold, ymold), RGB(0, 0, 0)
frmClock.Line (x1, y1)-(X, Y), colour
xmold = X
ymold = Y

Case 2
frmClock.Line (x1, y1)-(xhold, yhold), RGB(0, 0, 0)
frmClock.Line (x1, y1)-(X, Y), colour
xhold = X
yhold = Y
End Select


End Sub


		

提交新版本

如果您修改了一个代码片段并且觉得很应该让别人共享,您可以把这作为这个代码片段的最新版本提交上来.


联盟团体会员
合作伙伴
© 共创软件联盟 版权所有
联盟服务条款 | 联盟隐私权规则 | 联系我们
电话: (8610)68313388-5949 | 传真: (8610)88377936
京ICP备05056057号