用VB編鐘表,錶針運動程式怎麼編

2022-12-28 01:05:35 字數 3174 閱讀 1991

1樓:

這個比較麻煩,我曾經寫過這麼個程式片段,現在貼上來,**比較複雜

shape1是時鐘的一個框,是shape控制元件,設定 height 1455 width 1575

linehour,lineminute,linesecond分別為時,分,秒針,為line控制元件

label3,label6,label9,label12為label控制元件,分別為3.6.912點的顯示數字

再畫個timer控制元件,interval設定為1000

以上控制元件位置隨便放,**裡調整

form_load事件裡寫

shape1.top = 100

shape1.left = me.width - 1800

linehour.x1 = shape1.left + shape1.width / 2

linehour.y1 = shape1.top + shape1.height / 2

lineminute.x1 = shape1.left + shape1.width / 2

lineminute.y1 = shape1.top + shape1.height / 2

linesecond.x1 = shape1.left + shape1.width / 2

linesecond.y1 = shape1.top + shape1.height / 2

label3.left = shape1.left + shape1.width - label3.width - 200

label3.top = shape1.top + (shape1.height - label3.height) / 2

label6.left = shape1.left + (shape1.width - label6.width) / 2

label6.top = shape1.top + shape1.height - label6.height + 20

label9.left = shape1.left + 200

label9.top = shape1.top + (shape1.height - label9.height) / 2

label12.left = shape1.left + (shape1.width - label12.width) / 2

label12.top = shape1.top + 100

timer事件裡寫

'利用label顯示數字

if shape1.visible <> true then shape1.visible = true

if linehour.visible <> true then linehour.visible = true

if lineminute.visible <> true then lineminute.visible = true

if linesecond.visible <> true then linesecond.visible = true

if label3.visible <> true then label3.visible = true

if label6.visible <> true then label6.visible = true

if label9.visible <> true then label9.visible = true

if label12.visible <> true then label12.visible = true

dim cx as single, cy as single '圓心座標

cx = shape1.left + shape1.width / 2

cy = shape1.top + shape1.height / 2

'利用line控制元件繪製指標

linesecond.x2 = linesecond.x1 + sin(clng(second(now)) / 60 * 2 * pi) * 480

linesecond.y2 = linesecond.y1 - cos(clng(second(now)) / 60 * 2 * pi) * 480

lineminute.x2 = lineminute.x1 + sin(clng(minute(now)) / 60 * 2 * pi) * 360

lineminute.y2 = lineminute.y1 - cos(clng(minute(now)) / 60 * 2 * pi) * 360

linehour.x2 = linehour.x1 + sin((clng(hour(now)) + clng(minute(now)) / 60) / 12 * 2 * pi) * 240

linehour.y2 = linehour.y1 - cos((clng(hour(now)) + clng(minute(now)) / 60) / 12 * 2 * pi) * 240

'利用line方法繪製刻度

me.line (cx + 250, cy - 433.012701892219)-(cx + 300, cy - 519.615242270663)

me.line (cx + 433.012701892219, cy - 250)-(cx + 519.615242270663, cy - 300)

me.line (cx + 433.012701892219, cy + 250)-(cx + 519.615242270663, cy + 300)

me.line (cx + 250, cy + 433.012701892219)-(cx + 300, cy + 519.615242270663)

me.line (cx - 250, cy + 433.012701892219)-(cx - 300, cy + 519.615242270663)

me.line (cx - 433.012701892219, cy + 250)-(cx - 519.615242270663, cy + 300)

me.line (cx - 433.012701892219, cy - 250)-(cx - 519.615242270663, cy - 300)

me.line (cx - 250, cy - 433.012701892219)-(cx - 300, cy - 519.615242270663)

2樓:甄春嬌

這個要在程式設計中新增一個flash才行

我以前也試過,很簡單的!

vb怎麼用,vb程式碼怎麼用

private sub timer1 timer if i 0 then print 我是中國人 end if if i 1 then print 中國人 end if if i 2 then print 中國vs小日本 end if i i 1 end sub 我給你的 就是放一個銨鈕一個計時器 ...

用vb編寫1 3 599的問題,用VB迴圈結構怎麼求1 3

因為你是從1到99奇數相加,所以i 1 to 99 step 2。command click 名字錯了,少了一個1,應command1 click private sub command1 click dim i,sum sum 0 for i 1 to 99 step 2sum sum i nex...

用VB程式設計s 1 2 3n,用VB程式設計計算 1! 2! 3! 4! n

private sub command1 click dim n as integer i as integer,s as integer l as integer,k as integer n val inputbox for l 1 to n s 1 for i l to 1 step 1s s...