VB电子钟

VB电子钟

题目
VB电子钟
由分针、时针、秒针组成,并且显示在PICTURE1里面,下面标有日期
答案
Dim day, year, month, ddate, ttime As String
Dim alf(0 To 11)
Dim rr
Dim nhourlen, nminlen, nseclen As Integer
Const pi = 3.14159265358979
Private Sub Form_Load()
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
rr = pictime.Height / 2
ddate = Format(Now, "mm:dd:yy")
ttime = Format(Now, "hh:mm:ss")
month = Left(ddate, 2)
day = Mid(ddate, 4, 2)
year = Right(ddate, 2)
hh = Left(ttime, 2)
mm = Mid(ttime, 4, 2)
ss = Right(ttime, 2)
txtyear.Text = "20" & year
txtmth.Text = month
txtday.Text = day
lbltime.Caption = Time
nwidth = pictime.Width - 40
nhourlen = nwidth * 4 / 18
nminlen = nwidth * 6 / 18
nseclen = nwidth * 8 / 18
alfsec = ((ss - 15) / 30) * pi
alfmin = ((mm + ss / 60 - 15) / 30) * pi
alfhour = ((hh + mm / 60 + ss / 3600 - 15) / 6) * pi
pictime.Refresh
For i = 0 To 11
alf(i) = i * 30 * pi / 180
pictime.DrawWidth = 1
If i = 0 Or i = 3 Or i = 6 Or i = 9 Then
pictime.DrawWidth = 3
End If
pictime.Line (rr + (rr - 100) * Cos(alf(i)), rr + (rr - 100) * Sin(alf(i)))-(rr + (rr - 300) * Cos(alf(i)), rr + (rr - 300) * Sin(alf(i))), RGB(255, 0, 255)
Next i
pictime.DrawWidth = 3
pictime.Line (rr, rr)-(rr + nhourlen * Cos(alfhour), rr + nhourlen * Sin(alfhour))
pictime.DrawWidth = 2
pictime.Line (rr, rr)-(rr + nminlen * Cos(alfmin), rr + nminlen * Sin(alfmin))
pictime.DrawWidth = 1
pictime.Line (rr, rr)-(rr + nseclen * Cos(alfsec), rr + nseclen * Sin(alfsec))
pictime.DrawWidth = 5
pictime.PSet (rr, rr), RGB(255, 0, 255)
End Sub
注 你的PICTURE1是PICTURE BOX 并改名为PICTIME
同时添加1个时间控件TIMER1 3个TEXT BOX 并分别命名为txtyear, txtmth ,txtday
1个LABEL 命名为LBLTIME就可以了
举一反三
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
1,人们染上烟瘾,最终因吸烟使自己丧命.
最新试题
热门考点

超级试练试题库

© 2017-2019 超级试练试题库,All Rights Reserved.