vbnet左右移動(dòng) vb上下移動(dòng)

在VB.NET中,關(guān)于top、bottom、left、right的問(wèn)題

這可以理解,bottom,right代表控件底和右部邊界的坐標(biāo)值,而非高度和寬度。移動(dòng)的話對(duì)邊的邊界自然同步移動(dòng)的了。

創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供弓長(zhǎng)嶺網(wǎng)站建設(shè)、弓長(zhǎng)嶺做網(wǎng)站、弓長(zhǎng)嶺網(wǎng)站設(shè)計(jì)、弓長(zhǎng)嶺網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、弓長(zhǎng)嶺企業(yè)網(wǎng)站模板建站服務(wù),十多年弓長(zhǎng)嶺做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。

VB 中如何實(shí)現(xiàn)左右移動(dòng)

要加一個(gè)計(jì)時(shí)器

timer1

Private

Sub

Form_Load()

Timer1.Interval

=

100

Timer1.Enabled

=

True

'每100

毫秒檢查一次

End

Sub

Private

Sub

Timer1_Timer()

'利用if語(yǔ)句判斷Label的位置

If

Label1.Left

Val(Form1.Width)

Then

'Label尚未完全左移出窗體時(shí)

Label1.Left

=

Label1.Left

+

100

Else

Label1.Left

=

-

Val(Label1.Width)

'Label從窗體左側(cè)出現(xiàn)

End

If

End

Sub

你好,請(qǐng)教一下vb.net中想實(shí)現(xiàn)標(biāo)簽自動(dòng)從左到右移動(dòng)如何實(shí)現(xiàn),我是新手

見(jiàn)下面代碼,放置定時(shí)器,按鈕,標(biāo)簽各一個(gè)

Public?Class?Form1

Private?Sub?Timer1_Tick(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Timer1.Tick?'定時(shí)器

If?Label1.Right??Me.Width?Then

Label1.Left?+=?10'移動(dòng)距離

Else

Label1.Left?=?0

End?If

End?Sub

Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click?'開(kāi)啟或者關(guān)閉定時(shí)器

Timer1.Interval?=?1000?'1秒

If?Timer1.Enabled?=?False?Then

Timer1.Start()?'開(kāi)定時(shí)器

Else

Timer1.Stop()?'關(guān)定時(shí)器

End?If

End?Sub

End?Class

用VB.NET怎么編寫這個(gè)程序:“設(shè)計(jì)流動(dòng)字幕版,實(shí)現(xiàn)字幕從左到右河從右到左移動(dòng)的效果”

'-------不知你是否是要實(shí)現(xiàn)左右來(lái)回移動(dòng)-----------

'添加控件label1

'添加控件Timer1

'設(shè)置Timer1.enabled=True

'添加Timer1_Tick事件

'代碼如下:

Dim dir As Boolean = False

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

Dim x As Integer = Me.Label1.Location.X

Dim y As Integer = Me.Label1.Location.Y

Dim pointxy As New Point(x, y)

If x = 0 Then

dir = False

ElseIf x = Me.Width - Me.Label1.Width Then

dir = True

End If

If dir Then

pointxy = New Point(x - 1, y)

Else

pointxy = New Point(x + 1, y)

End If

Me.Label1.Location = pointxy

End Sub

vb使按鈕左右移動(dòng)

比如有3個(gè)按鈕,1,2,3,3在1,2之間。

取得1按鈕的右邊位置,left屬性+width屬性,2按鈕的左位置,就是left屬性。

再定位3的left就可以了。

Dim

a

Private

Sub

Command2_Click()

Timer1.Enabled

=

True

End

Sub

Private

Sub

Form_Click()

Timer1.Enabled

=

False

End

Sub

Private

Sub

Form_Load()

Timer1.Interval

=

100

a

=

20

End

Sub

Private

Sub

Timer1_Timer()

If

Command3.Left

Command1.Left

+

Command1.Width

Then

a

=

20

If

Command3.Left

+

Command3.Width

Command2.Left

Then

a

=

-20

Command3.Left

=

Command3.Left

+

a

End

Sub

當(dāng)前題目:vbnet左右移動(dòng) vb上下移動(dòng)
文章網(wǎng)址:http://muchs.cn/article36/docdisg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁(yè)設(shè)計(jì)公司建站公司、網(wǎng)站建設(shè)云服務(wù)器、網(wǎng)站排名、網(wǎng)站內(nèi)鏈

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

手機(jī)網(wǎng)站建設(shè)