用VB制作指针时钟。要详细的步骤和控件名称
使用VB制作一个指针式时钟,本课题使用直线控件作为时钟的指针,再使用定时器控件控制直线控件的位置,从而使得直线控件能象时钟中的指针一样顺时针转动。邮箱734933892@...
使用VB制作一个指针式时钟,本课题使用直线控件作为时钟的指针,再使用定时器控件控制直线控件的位置,从而使得直线控件能象时钟中的指针一样顺时针转动。
邮箱734933892@qq.com 展开
邮箱734933892@qq.com 展开
2个回答
2011-01-08
展开全部
窗体上加一个timer1,intervar设为1000(毫秒);加3个line,3个line的x1、y1相同;一个shape控件,shape属性设为3,圆心为x1,y1,把下面代码拷贝到窗体代码中,运行即可
如果觉得可以的话,加点分哈└(^o^)┘
Const pi = 3.14159
Dim len1, len2, len3 As Single
Private Sub Form_Load()
len1 = Sqr((Abs((Line1.Y2 - Line1.Y1))) ^ 2 + (Abs(Line1.X2 - Line1.X1)) ^ 2)
len2 = Sqr((Abs((Line2.Y2 - Line2.Y1))) ^ 2 + (Abs(Line2.X2 - Line2.X1)) ^ 2)
len3 = Sqr((Abs((Line3.Y2 - Line3.Y1))) ^ 2 + (Abs(Line3.X2 - Line3.X1)) ^ 2)
End Sub
Private Sub timer1_timer()
s = Second(Time)
m = Minute(Time)
h = Hour(Time) + m / 60
Line1.X2 = Line1.X1 + len1 * Sin(pi * s / 30)
Line1.Y2 = Line1.Y1 - len1 * Cos(pi * s / 30)
Line2.X2 = Line2.X1 + len2 * Sin(pi * m / 30)
Line2.Y2 = Line2.Y1 - len2 * Cos(pi * m / 30)
If h >= 12 Then h = h - 12
Line3.X2 = Line3.X1 + len3 * Sin(pi * h / 6)
Line3.Y2 = Line3.Y1 - len3 * Cos(pi * h / 6)
End Sub
如果觉得可以的话,加点分哈└(^o^)┘
Const pi = 3.14159
Dim len1, len2, len3 As Single
Private Sub Form_Load()
len1 = Sqr((Abs((Line1.Y2 - Line1.Y1))) ^ 2 + (Abs(Line1.X2 - Line1.X1)) ^ 2)
len2 = Sqr((Abs((Line2.Y2 - Line2.Y1))) ^ 2 + (Abs(Line2.X2 - Line2.X1)) ^ 2)
len3 = Sqr((Abs((Line3.Y2 - Line3.Y1))) ^ 2 + (Abs(Line3.X2 - Line3.X1)) ^ 2)
End Sub
Private Sub timer1_timer()
s = Second(Time)
m = Minute(Time)
h = Hour(Time) + m / 60
Line1.X2 = Line1.X1 + len1 * Sin(pi * s / 30)
Line1.Y2 = Line1.Y1 - len1 * Cos(pi * s / 30)
Line2.X2 = Line2.X1 + len2 * Sin(pi * m / 30)
Line2.Y2 = Line2.Y1 - len2 * Cos(pi * m / 30)
If h >= 12 Then h = h - 12
Line3.X2 = Line3.X1 + len3 * Sin(pi * h / 6)
Line3.Y2 = Line3.Y1 - len3 * Cos(pi * h / 6)
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询