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就可以了
举一反三
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
最新试题
- 如果谁读过《马价十倍》这篇短文就帮帮我!
- The girl can ________ tennis well .A.playing B.plays C.play
- 1/(x^2+3x+2)+1/(x^2+5x+6)+1/(x^2+7x+12)+1/(x^2+9x+20) 化简,不是解方程.急.
- 已知直线L经过点P(1,1),倾斜角为30°1)写出直线方程2)设L与圆X2+Y2=4相交于两ABl两点的距离之和
- 哪些数既是15的因数,也是20的因数
- 我梦想来到塞外的大漠,在夕阳的余晖中感受"长河落日圆"的壮丽.我梦想__________?我梦想__________?
- 求证:在区间(1,+无穷)上,函数f(x)=1/2x^2+lnx的图像总在函数g(x)=2/3x^3的下方
- 氯化银是什么状沉淀
- be的现在分词和过去式是什么?
- _ in the 1900s most American towns and cities had a Main Street.A,As early as B,Early C,Early as D
热门考点