用VB.NET怎么编写这个程序:“设计流动字幕版,实现字幕从左到右河从右到左移动的效果”

来源:百度知道 编辑:UC知道 时间:2024/05/24 15:45:54

'-------不知你是否是要实现左右来回移动-----------
'添加控件label1
'添加控件Timer1
'设置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