1樓:匿名使用者
新增一個標籤框,一個計時器,然後新增如下**,執行試試private sub form_load()label1.caption = "示例程式"
label1.backcolor = vbblacklabel1.forecolor = vbgreenlabel1.
autosize = truelabel1.move 0, (form1.scaleheight - label1.
height) / 2
timer1.interval = 10
timer1.enabled = trueend sub
private sub timer1_timer()static fx as boolean
label1.move label1.left + iif(fx = false, 30, -30)
if fx = true then
if label1.left < 0 then fx = falseelse
if label1.left > form1.scalewidth - label1.width then fx = true
end if
end sub
2樓:匿名使用者
a:窗體的左緣+窗體寬度=當前窗體右緣的象素位置b:標籤左緣+標籤寬度=當前標籤右緣的畫素位置設定計時器後,計算a-b,等於0的時候說明標籤右端已經碰到窗體的最右邊了。
同樣的,你可以類推出窗體的左緣-標籤左緣=0時,到達左邊這樣的問題你設定兩個計時器更好,比較清晰一點,一個管往左邊移,另一個管往右邊移動。記得其中一個計時器啟動的時候要把另一個disable掉哦
3樓:匿名使用者
一個command和一個label控制元件 一個timer時間控制元件,已經試驗過了,成功,你可以再form中對label各個屬性進行設定。
dim s as boolean
private sub command1_click()if command1.caption = "開始" thencommand1.caption = "暫停"
timer1.enabled = trueelse
command1.caption = "開始"
timer1.enabled = falseend if
end sub
private sub form_load()command1.caption = "開始"
timer1.interval = 30
timer1.enabled = falses = true
end sub
private sub timer1_timer()if s then
if label1.left > 0 thenlabel1.left = label1.left - 10else
s = false
end if
else
if label1.left < (form1.width - label1.width) then
label1.left = label1.left + 10else
s = true
end if
end if
end sub
4樓:墨漬
public a as integer
private sub form_load()timer1.interval = 10
a = 10
end sub
private sub timer1_timer()label1.left = label1.left - aif label1.
left < 0 or label1.left > form1.width - label1.
width then
a = -a
end if
end sub
有關vb的timer控制元件的問題
建立一個timer控制元件,一個文字框,一個按鈕。先把timer的interval屬性值改成100通用宣告 如下 dim t as single t 0text1.text 0 按鈕的 如下 if timer1.enabled true thentimer1.enabled false else t...
一個vb控制元件的問題,關於VB模組的問題
在窗體上新增兩個命令按鈕,將第二個命令按鈕command2的index屬性設定為0,下面的 實現點選command1按鈕,將新增一個按鈕,並自動排列。option explicit 輸出十個命令控制元件。dim i as integer private sub command1 click i i ...
vb的tet控制元件怎麼換行,VB的TEXT控制元件怎麼換行
除設定文字框屬性multiline為true外,如下 private sub form load text1 123 vbnewline 456 end sub 1,先在窗體新增 text1控制元件 2,設定 text1.multiline true3,在text1控制元件顯示中,新增換行資訊,如 ...