我用VB编好了一个时钟的程序,如下,我怎么修改可以让程序中的时针、分针、秒针,随系统时间走动呢?帮帮
Constpi=3.1415926PrivateSubForm_Load()DimtAsDateDimsAsIntegerDimmAsIntegerDimhAsInteg...
Const pi = 3.1415926
Private Sub Form_Load()
Dim t As Date
Dim s As Integer
Dim m As Integer
Dim h As Integer
t = Time()
s = Second(t)
lins.X2 = lins.X1 + 3200 * Sin(6 * s * pi / 180)
lins.Y2 = lins.Y1 - 3200 * Cos(6 * s * pi / 180)
m = Minute(t)
linf.X2 = linf.X1 + 2600 * Sin(6 * m * pi / 180)
linf.Y2 = linf.Y1 - 2600 * Cos(6 * m * pi / 180)
h = Hour(t)
linh.X2 = linh.X1 + 2000 * Sin((30 * h + 0.5 * m) * pi / 180)
linh.Y2 = linh.Y1 - 2000 * Cos((30 * h + 0.5 * m) * pi / 180)
End Sub 展开
Private Sub Form_Load()
Dim t As Date
Dim s As Integer
Dim m As Integer
Dim h As Integer
t = Time()
s = Second(t)
lins.X2 = lins.X1 + 3200 * Sin(6 * s * pi / 180)
lins.Y2 = lins.Y1 - 3200 * Cos(6 * s * pi / 180)
m = Minute(t)
linf.X2 = linf.X1 + 2600 * Sin(6 * m * pi / 180)
linf.Y2 = linf.Y1 - 2600 * Cos(6 * m * pi / 180)
h = Hour(t)
linh.X2 = linh.X1 + 2000 * Sin((30 * h + 0.5 * m) * pi / 180)
linh.Y2 = linh.Y1 - 2000 * Cos((30 * h + 0.5 * m) * pi / 180)
End Sub 展开
展开全部
添加一个Timer时钟控件,把Timer1的Interval值设为1000,把Form_Load()事件里的代码移到Timer_Timer()事件里
Const pi = 3.1415926
Private Sub Timer1_Timer()
Dim t As Date
Dim s As Integer
Dim m As Integer
Dim h As Integer
t = Time()
s = Second(t)
lins.X2 = lins.X1 + 3200 * Sin(6 * s * pi / 180)
lins.Y2 = lins.Y1 - 3200 * Cos(6 * s * pi / 180)
m = Minute(t)
linf.X2 = linf.X1 + 2600 * Sin(6 * m * pi / 180)
linf.Y2 = linf.Y1 - 2600 * Cos(6 * m * pi / 180)
h = Hour(t)
linh.X2 = linh.X1 + 2000 * Sin((30 * h + 0.5 * m) * pi / 180)
linh.Y2 = linh.Y1 - 2000 * Cos((30 * h + 0.5 * m) * pi / 180)
End Sub
Const pi = 3.1415926
Private Sub Timer1_Timer()
Dim t As Date
Dim s As Integer
Dim m As Integer
Dim h As Integer
t = Time()
s = Second(t)
lins.X2 = lins.X1 + 3200 * Sin(6 * s * pi / 180)
lins.Y2 = lins.Y1 - 3200 * Cos(6 * s * pi / 180)
m = Minute(t)
linf.X2 = linf.X1 + 2600 * Sin(6 * m * pi / 180)
linf.Y2 = linf.Y1 - 2600 * Cos(6 * m * pi / 180)
h = Hour(t)
linh.X2 = linh.X1 + 2000 * Sin((30 * h + 0.5 * m) * pi / 180)
linh.Y2 = linh.Y1 - 2000 * Cos((30 * h + 0.5 * m) * pi / 180)
End Sub
展开全部
用一个TIMER控件,把代码放到TIMER里面去
Const pi = 3.1415926
Private Sub Form_Load()
Dim t As Date
Dim s As Integer
Dim m As Integer
Dim h As Integer
t = Time()
s = Second(t)
Lins.X2 = Lins.X1 + 3200 * Sin(6 * s * pi / 180)
Lins.Y2 = Lins.Y1 - 3200 * Cos(6 * s * pi / 180)
m = Minute(t)
Linf.X2 = Linf.X1 + 2600 * Sin(6 * m * pi / 180)
Linf.Y2 = Linf.Y1 - 2600 * Cos(6 * m * pi / 180)
h = Hour(t)
Linh.X2 = Linh.X1 + 2000 * Sin((30 * h + 0.5 * m) * pi / 180)
Linh.Y2 = Linh.Y1 - 2000 * Cos((30 * h + 0.5 * m) * pi / 180)
End Sub
Private Sub Timer1_Timer()
Dim t As Date
Dim s As Integer
Dim m As Integer
Dim h As Integer
t = Time()
s = Second(t)
Lins.X2 = Lins.X1 + 3200 * Sin(6 * s * pi / 180)
Lins.Y2 = Lins.Y1 - 3200 * Cos(6 * s * pi / 180)
m = Minute(t)
Linf.X2 = Linf.X1 + 2600 * Sin(6 * m * pi / 180)
Linf.Y2 = Linf.Y1 - 2600 * Cos(6 * m * pi / 180)
h = Hour(t)
Linh.X2 = Linh.X1 + 2000 * Sin((30 * h + 0.5 * m) * pi / 180)
Linh.Y2 = Linh.Y1 - 2000 * Cos((30 * h + 0.5 * m) * pi / 180)
End Sub
Const pi = 3.1415926
Private Sub Form_Load()
Dim t As Date
Dim s As Integer
Dim m As Integer
Dim h As Integer
t = Time()
s = Second(t)
Lins.X2 = Lins.X1 + 3200 * Sin(6 * s * pi / 180)
Lins.Y2 = Lins.Y1 - 3200 * Cos(6 * s * pi / 180)
m = Minute(t)
Linf.X2 = Linf.X1 + 2600 * Sin(6 * m * pi / 180)
Linf.Y2 = Linf.Y1 - 2600 * Cos(6 * m * pi / 180)
h = Hour(t)
Linh.X2 = Linh.X1 + 2000 * Sin((30 * h + 0.5 * m) * pi / 180)
Linh.Y2 = Linh.Y1 - 2000 * Cos((30 * h + 0.5 * m) * pi / 180)
End Sub
Private Sub Timer1_Timer()
Dim t As Date
Dim s As Integer
Dim m As Integer
Dim h As Integer
t = Time()
s = Second(t)
Lins.X2 = Lins.X1 + 3200 * Sin(6 * s * pi / 180)
Lins.Y2 = Lins.Y1 - 3200 * Cos(6 * s * pi / 180)
m = Minute(t)
Linf.X2 = Linf.X1 + 2600 * Sin(6 * m * pi / 180)
Linf.Y2 = Linf.Y1 - 2600 * Cos(6 * m * pi / 180)
h = Hour(t)
Linh.X2 = Linh.X1 + 2000 * Sin((30 * h + 0.5 * m) * pi / 180)
Linh.Y2 = Linh.Y1 - 2000 * Cos((30 * h + 0.5 * m) * pi / 180)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
吧Dim t As Date
Dim s As Integer
Dim m As Integer
Dim h As Integer
t = Time()
s = Second(t)
lins.X2 = lins.X1 + 3200 * Sin(6 * s * pi / 180)
lins.Y2 = lins.Y1 - 3200 * Cos(6 * s * pi / 180)
m = Minute(t)
linf.X2 = linf.X1 + 2600 * Sin(6 * m * pi / 180)
linf.Y2 = linf.Y1 - 2600 * Cos(6 * m * pi / 180)
h = Hour(t)
linh.X2 = linh.X1 + 2000 * Sin((30 * h + 0.5 * m) * pi / 180)
linh.Y2 = linh.Y1 - 2000 * Cos((30 * h + 0.5 * m) * pi / 180)这一段放到一个timer控件的过程里就行了,Interval设为100(0.1秒刷新)或1000(1秒刷新)。
Dim s As Integer
Dim m As Integer
Dim h As Integer
t = Time()
s = Second(t)
lins.X2 = lins.X1 + 3200 * Sin(6 * s * pi / 180)
lins.Y2 = lins.Y1 - 3200 * Cos(6 * s * pi / 180)
m = Minute(t)
linf.X2 = linf.X1 + 2600 * Sin(6 * m * pi / 180)
linf.Y2 = linf.Y1 - 2600 * Cos(6 * m * pi / 180)
h = Hour(t)
linh.X2 = linh.X1 + 2000 * Sin((30 * h + 0.5 * m) * pi / 180)
linh.Y2 = linh.Y1 - 2000 * Cos((30 * h + 0.5 * m) * pi / 180)这一段放到一个timer控件的过程里就行了,Interval设为100(0.1秒刷新)或1000(1秒刷新)。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
没有定义各线的初始位置,直接调到窗口中心吧,加个timer控件:
Private Sub Form_Load()
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Const pi = 3.1415926
Dim t As Date
Dim s As Integer
Dim m As Integer
Dim h As Integer
t = Time()
s = Second(t)
Line1.X1 = Me.Width / 2
Line3.X1 = Me.Width / 2
Line2.X1 = Me.Width / 2
Line1.Y1 = Me.Height / 2
Line2.Y1 = Me.Height / 2
Line3.Y1 = Me.Height / 2
Line1.X2 = Line1.X1 + 3200 * Sin(6 * s * pi / 180)
Line1.Y2 = Line1.Y1 - 3200 * Cos(6 * s * pi / 180)
m = Minute(t)
Line2.X2 = Line2.X1 + 2600 * Sin(6 * m * pi / 180)
Line2.Y2 = Line2.Y1 - 2600 * Cos(6 * m * pi / 180)
h = Hour(t)
Line3.X2 = Line3.X1 + 2000 * Sin((30 * h + 0.5 * m) * pi / 180)
Line3.Y2 = Line3.Y1 - 2000 * Cos((30 * h + 0.5 * m) * pi / 180)
End Sub
Private Sub Form_Load()
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Const pi = 3.1415926
Dim t As Date
Dim s As Integer
Dim m As Integer
Dim h As Integer
t = Time()
s = Second(t)
Line1.X1 = Me.Width / 2
Line3.X1 = Me.Width / 2
Line2.X1 = Me.Width / 2
Line1.Y1 = Me.Height / 2
Line2.Y1 = Me.Height / 2
Line3.Y1 = Me.Height / 2
Line1.X2 = Line1.X1 + 3200 * Sin(6 * s * pi / 180)
Line1.Y2 = Line1.Y1 - 3200 * Cos(6 * s * pi / 180)
m = Minute(t)
Line2.X2 = Line2.X1 + 2600 * Sin(6 * m * pi / 180)
Line2.Y2 = Line2.Y1 - 2600 * Cos(6 * m * pi / 180)
h = Hour(t)
Line3.X2 = Line3.X1 + 2000 * Sin((30 * h + 0.5 * m) * pi / 180)
Line3.Y2 = Line3.Y1 - 2000 * Cos((30 * h + 0.5 * m) * pi / 180)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询