钟表的指针,用vb怎么编写
怎么修改此程序段可以该为钟表指针PrivateSubForm_Load()Form1.ScaleLeft=-2000Form1.ScaleTop=1500Form1.Sc...
怎么修改此程序段可以该为钟表指针
Private Sub Form_Load()
Form1.ScaleLeft = -2000
Form1.ScaleTop = 1500
Form1.ScaleWidth = 4000
Form1.ScaleHeight = -3000
End Sub
Private Sub Timer1_Timer()
d = 1400
s = Second(Time)
a = d * Sin(PI * s / 30)
b = d * Cos(PI * s / 30)
c = 50
e = (b + c) * a * b / (a * a + b * b)
f = (b + c) * a * a / (a * a + b * b) - c
g = (b - c) * a * b / (a * a + b * b)
h = (b - c) * a * a / (a * a + b * b) + c
Line (0, 0)-(e, f), RGB(255, 0, 0)
Line (e, f)-(a, b), RGB(255, 0, 0)
Line (a, b)-(g, h), RGB(255, 0, 0)
Line (g, h)-(0, 0), RGB(255, 0, 0)
End Sub 展开
Private Sub Form_Load()
Form1.ScaleLeft = -2000
Form1.ScaleTop = 1500
Form1.ScaleWidth = 4000
Form1.ScaleHeight = -3000
End Sub
Private Sub Timer1_Timer()
d = 1400
s = Second(Time)
a = d * Sin(PI * s / 30)
b = d * Cos(PI * s / 30)
c = 50
e = (b + c) * a * b / (a * a + b * b)
f = (b + c) * a * a / (a * a + b * b) - c
g = (b - c) * a * b / (a * a + b * b)
h = (b - c) * a * a / (a * a + b * b) + c
Line (0, 0)-(e, f), RGB(255, 0, 0)
Line (e, f)-(a, b), RGB(255, 0, 0)
Line (a, b)-(g, h), RGB(255, 0, 0)
Line (g, h)-(0, 0), RGB(255, 0, 0)
End Sub 展开
2个回答
展开全部
Const pi = 3.14159265
Private Const sLeng = 80
Private Const mLeng = 70
Private Const hLeng = 40
Dim s As Integer
Dim m As Integer
Dim h As Single
Private Sub Form_Load()
Me.AutoRedraw = True
Me.ScaleMode = vbPixels
Me.DrawMode = vbNotXorPen
End Sub
Private Sub Form_Resize()
On Error GoTo errMsg:
Me.Scale (-Me.ScaleWidth / 2, -Me.ScaleHeight / 2)-(Me.ScaleWidth / 2, Me.ScaleHeight / 2)
Cls
Me.DrawWidth = 1
Circle (0, 0), 100
Form1.Caption = Format(Time, "medium time")
s = Second(Time)
m = Minute(Time)
h = Hour(Time) + m / 60
If h >= 12 Then h = h - 12
Line (0, 0)-(sLeng * Cos(pi * s / 30), sLeng * Sin(pi * s / 30)), vbRed
Line (0, 0)-(mLeng * Cos(pi * m / 30), mLeng * Sin(pi * m / 30)), vbBlue
Line (0, 0)-(hLeng * Cos(pi * h / 6), hLeng * Sin(pi * h / 6)), vbBlack
Exit Sub
errMsg:
Me.Caption = "窗体被你拖得太小啦!"
End Sub
Private Sub Timer1_Timer()
Line (0, 0)-(sLeng * Cos(pi * s / 30), sLeng * Sin(pi * s / 30)), vbRed
Line (0, 0)-(mLeng * Cos(pi * m / 30), mLeng * Sin(pi * m / 30)), vbBlue
Line (0, 0)-(hLeng * Cos(pi * h / 6), hLeng * Sin(pi * h / 6)), vbBlack
Form1.Caption = Format(Time, "medium time")
s = Second(Time)
m = Minute(Time)
h = Hour(Time) + m / 60
If h >= 12 Then h = h - 12
Line (0, 0)-(sLeng * Cos(pi * s / 30), sLeng * Sin(pi * s / 30)), vbRed '秒针
Line (0, 0)-(mLeng * Cos(pi * m / 30), mLeng * Sin(pi * m / 30)), vbBlue '分针
Line (0, 0)-(hLeng * Cos(pi * h / 6), hLeng * Sin(pi * h / 6)), vbBlack '时针
End Sub
Private Const sLeng = 80
Private Const mLeng = 70
Private Const hLeng = 40
Dim s As Integer
Dim m As Integer
Dim h As Single
Private Sub Form_Load()
Me.AutoRedraw = True
Me.ScaleMode = vbPixels
Me.DrawMode = vbNotXorPen
End Sub
Private Sub Form_Resize()
On Error GoTo errMsg:
Me.Scale (-Me.ScaleWidth / 2, -Me.ScaleHeight / 2)-(Me.ScaleWidth / 2, Me.ScaleHeight / 2)
Cls
Me.DrawWidth = 1
Circle (0, 0), 100
Form1.Caption = Format(Time, "medium time")
s = Second(Time)
m = Minute(Time)
h = Hour(Time) + m / 60
If h >= 12 Then h = h - 12
Line (0, 0)-(sLeng * Cos(pi * s / 30), sLeng * Sin(pi * s / 30)), vbRed
Line (0, 0)-(mLeng * Cos(pi * m / 30), mLeng * Sin(pi * m / 30)), vbBlue
Line (0, 0)-(hLeng * Cos(pi * h / 6), hLeng * Sin(pi * h / 6)), vbBlack
Exit Sub
errMsg:
Me.Caption = "窗体被你拖得太小啦!"
End Sub
Private Sub Timer1_Timer()
Line (0, 0)-(sLeng * Cos(pi * s / 30), sLeng * Sin(pi * s / 30)), vbRed
Line (0, 0)-(mLeng * Cos(pi * m / 30), mLeng * Sin(pi * m / 30)), vbBlue
Line (0, 0)-(hLeng * Cos(pi * h / 6), hLeng * Sin(pi * h / 6)), vbBlack
Form1.Caption = Format(Time, "medium time")
s = Second(Time)
m = Minute(Time)
h = Hour(Time) + m / 60
If h >= 12 Then h = h - 12
Line (0, 0)-(sLeng * Cos(pi * s / 30), sLeng * Sin(pi * s / 30)), vbRed '秒针
Line (0, 0)-(mLeng * Cos(pi * m / 30), mLeng * Sin(pi * m / 30)), vbBlue '分针
Line (0, 0)-(hLeng * Cos(pi * h / 6), hLeng * Sin(pi * h / 6)), vbBlack '时针
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询