作业帮 > 综合 > 作业

VB语言里面有这样一段:s = Second(Time) m = Minute(Time) + s / 60 h =

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/17 11:09:38
VB语言里面有这样一段:s = Second(Time) m = Minute(Time) + s / 60 h =
VB语言里面有这样一段:s = Second(Time) m = Minute(Time) + s / 60 h =
h=Hour(Time)+m/60
再问: 因为要制作一个指针时钟,您的答案我试过了,指的位置不对啊
再答: 窗体上加一个timer1,intervar设为1000(毫秒);加3个line,3个line的x1、y1相同;一个shape控件,shape属性设为3,圆心为x1,y1,把下面代码拷贝到窗体代码中,运行即可 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