1樓:
有沒有設定窗體座標系? timer隨便畫在哪 用到的只是它的sub timer1_timer()事件 line 時間設定它的起始點和終點畫線 通過設定窗體的drawwidth 屬性和forecolor來設定線條寬度和顏色
2樓:匿名使用者
在窗體中新增一個timer,一個label,三個line(位置隨便),**如下:
dim x0 as single 'x0,y0表示指標的圓心
dim y0 as single
private sub form_load()
randomize
x0 = 1500
y0 = 1500
timer1.interval = 1000
label1.backstyle = 0
label1.autosize = true
with form1
.width = 3150
.height = 3750
.caption = "模擬時鐘"
.backcolor = rgb(188, 238, 104)
end with
with line1 '時針
.borderwidth = 3
.x1 = x0
.y1 = y0
end with
with line2 '分針
.borderwidth = 2
.x1 = x0
.y1 = y0
end with
with line3 '秒針
.borderwidth = 1
.x1 = x0
.y1 = y0
end with
me.fillcolor = rgb(205, 190, 100 + 12 * rnd) '畫表盤輪廓圓,填色
me.fillstyle = 0
circle (x0, y0), 1350, qbcolor(rnd * 15)
me.fillstyle = 1
line1.visible = false
line2.visible = false
line3.visible = false
line1.bordercolor = vbyellow
line2.bordercolor = vbgreen
line3.bordercolor = vbred
end sub
private sub timer1_timer()
''''''''''''''''''''''''''''''''label1顯示日期
label1.caption = date
label1.left = 1150
label1.top = 1700
''''''''''''''''''''''''''''''
line1.visible = true
line2.visible = true
line3.visible = true
dim r0, r1, r2, r3 as integer
r0 = 1200 'r0表示刻度圓的半徑
r1 = 1000 '秒針半徑
r2 = 850
r3 = 600
''''''''''''''''''''''''''''' '畫12個大圈子
form1.fillcolor = rgb(205, 190, 100 + 12 * rnd)
form1.fillstyle = 0
for i = 1 to 12
y1 = y0 + r0 * sin((i * 30) * 3.1415926 / 180)
x1 = x0 + r0 * cos((i * 30) * 3.1415926 / 180)
circle (x1, y1), 40, rgb(rnd * 255, rnd * 255, rnd * 255)
me.fillstyle = 1
next i
''''''''''''''''''''''''''''''畫60個小圈子
for i = 1 to 60
if i <> 0 and i <> 5 and i <> 10 and i <> 15 and i <> 20 and i <> 25 and i <> 30 and i <> 35 and i <> 40 and i <> 45 and i <> 50 and i <> 55 and i <> 60 then
y1 = y0 + r0 * sin((i * 6) * 3.1415926 / 180)
x1 = x0 + r0 * cos((i * 6) * 3.1415926 / 180)
circle (x1, y1), 15, vbblack
end if
next i
'''''''''''''''''''''''''''''' '時針的轉動
with line1
.x2 = x0 - r3 * sin(-(hour(now) * 30 + minute(now) * 0.5) * 3.1415926 / 180)
.y2 = y0 - r3 * cos(-(hour(now) * 30 + minute(now) * 0.5) * 3.1415926 / 180)
end with
'''''''''''''''''''''''''''''''分針的轉動
with line2
.x2 = x0 - r2 * sin(-(minute(now) * 6) * 3.1415926 / 180)
.y2 = y0 - r2 * cos(-(minute(now) * 6) * 3.1415926 / 180)
end with
'''''''''''''''''''''''''''''''秒針的轉動
with line3
.x2 = x0 - r1 * sin(-(second(now) * 6) * 3.1415926 / 180)
.y2 = y0 - r1 * cos(-(second(now) * 6) * 3.1415926 / 180)
end with
circle (x0, y0), 35, vbblack '在指標中心畫一小圓
end sub
3樓:匿名使用者
是隨便新增就可以的
都沒辦法得到正確的時鐘
出什麼問題呢?
有些要在屬性裡設定的,比如line控制元件的粗細,顏色.
timer控制元件的interval屬性等
4樓:o黃師學子
hi 我 ~~我發給你 ~~
vb程式編寫
dim i as integer private sub form click form1.scale 0,20 20,0 i i 1 if i mod 3 1 then me.fillstyle 0 me.fillcolor vbred circle 10,10 2,vbred if i mod ...
VB編寫自動重複按鍵的問題,VB編寫自動按鍵時,不停按「下」怎麼寫
新增兩個timer,第一個enabled true,interval 100,第二個enabled fasle,interval 1000private declare function getasynckeystate lib user32 byval vkey as long as intege...
用vb編寫程式,計算
option explicitdim k,t as singleprivate sub mand1 click for k 2 to 300 step 2t t 1 k next label1.caption t end sub for i 2 to 300 step 2 sum 1 i sum n...