关于VB时钟移动的问题
要做一个时钟请教怎么利用键盘的方向上下来移动修改时间
Dim X0 As Integer, Y0 As Integer
Dim L As Integer
Const Pi = 3.1415926
Private Sub Command1_Click()
Do
h = Int(Val(InputBox("请输入你需要的小时数:", "修改", Hour(Now))))
Loop Until h >= 0 And h < 24
Do
m = Int(Val(InputBox("请输入你需要的分钟数:", "修改", Minute(Now))))
Loop Until m >= 0 And m < 60
Do
s = Int(Val(InputBox("请输入你需要的秒数:", "修改", Second(Now))))
Loop Until s >= 0 And s < 60
Label1 = Trim(Str(h)) & ":" & Trim(Str(m)) & ":" & Trim(Str(s))
End Sub
Private Sub Form_Activate()
For DU = 0 To 354 Step 6 '画秒刻度
xd = Cos(DU * Pi / 180) * (L - 100) + X0
yd = Sin(DU * Pi / 180) * (L - 100) + Y0
PSet (xd, yd), RGB(0, 0, 0)
Next
Me.FillColor = RGB(200, 200, 200)
For DU = 0 To 330 Step 30 '画5秒刻度
xd = Cos(DU * Pi / 180) * (L - 100) + X0
yd = Sin(DU * Pi / 180) * (L - 100) + Y0
Circle (xd, yd), 25
xd = Cos(DU * Pi / 180) * (L - 250) + X0
yd = Sin(DU * Pi / 180) * (L - 250) + Y0
CurrentX = xd - 100
CurrentY = yd - 100
If DU > 270 Then '写数字
Print DU / 30 - 9
Else
If DU = 270 Then CurrentX = CurrentX - 80
Print DU / 30 + 3
End If
Next
Me.FillColor = RGB(250, 100, 100) '画15秒刻度
For DU = 0 To 270 Step 90
xd = Cos(DU * Pi / 180) * (L - 100) + X0
yd = Sin(DU * Pi / 180) * (L - 100) + Y0
Circle (xd, yd), 40, RGB(0, 0, 255)
Next
End Sub
Private Sub Form_Load()
L = 2000 '长度基准,也是表盘的半径
Me.AutoRedraw = True
Me.Width = 4 * L
Me.Height = 3.5 * L
Me.FillColor = RGB(120, 250, 250)
Me.FillStyle = 0
X0 = Me.Width / 2 - 40
Y0 = Me.Height / 2 - 400
Line1.X1 = X0
Line1.Y1 = Y0
Line1.BorderWidth = 3
Line2.X1 = X0
Line2.Y1 = Y0
Line2.BorderWidth = 2
Shape1.Shape = 3 '秒针
Shape1.FillColor = RGB(255, 0, 0)
Shape1.FillStyle = 0
Shape1.Height = L / 12
Shape1.Width = L / 12
Shape1.BorderStyle = 0
Circle (X0, Y0), L '表盘
Me.FillColor = RGB(250, 0, 0)
Me.Circle (X0, Y0), L / 40, RGB(255, 0, 0) '中心
Timer1.Interval = 1000
Call Timer1_Timer
Command1.Caption = "修改时间"
Command1.Top = Me.Height - L * 3 / 4
Command1.Left = Me.Width - L * 3 / 4
Command1.Height = L / 3
Label1.Top = Command1.Top
Label1.Left = Width / 4
Label1.Width = Width / 3
Label1.FontSize = 24
Label1.Height = Command1.Height
Label1.Caption = ""
End Sub
Private Sub Timer1_Timer()
If Label1 = "" Then
t = Time
Else
t = CDate(Label1) + 1 / 24 / 60 / 60
End If
DU = Second(t) * 6 - 90 '制作秒针
Shape1.Top = Sin(DU * Pi / 180) * L * 0.85 + Y0 - Shape1.Height / 2
Shape1.Left = Cos(DU * Pi / 180) * L * 0.85 + X0 - Shape1.Width / 2
m = L * 0.7 '制作分针
DU = Minute(t) * 6 - 90 '+ Second(T) * 6 / 60
Line2.X2 = Cos(DU * Pi / 180) * m + X0
Line2.Y2 = Sin(DU * Pi / 180) * m + Y0
h = L * 0.6 '制作时针
DU = (Hour(t) Mod 12) * 30 + Minute(t) * 6 / 12 - 90
Line1.X2 = Cos(DU * Pi / 180) * h + X0
Line1.Y2 = Sin(DU * Pi / 180) * h + Y0
Label1 = t
End Sub