Marquee Project

Form 1
Private Sub Marquee(ByVal aCtrl As Control, ByVal Direction As Byte, Optional ByVal Speed As Integer = 3)

        Select Case Direction
            Case 0 'Leftwards
                If aCtrl.Left <= 0 - aCtrl.Width Then
                    aCtrl.Left = Me.Width
                Else
                    aCtrl.Left = aCtrl.Left - Speed
                End If
            Case 1 'Rightwards
                If aCtrl.Left >= Me.Width Then
                    aCtrl.Left = 0 - aCtrl.Width
                Else
                    aCtrl.Left = aCtrl.Left + Speed
                End If
            Case 2 'Upwards
                If aCtrl.Top <= 0 - aCtrl.Height Then
                    aCtrl.Top = Me.Height
                Else
                    aCtrl.Top = aCtrl.Top - Speed
                End If
            Case 3 'Downwards
                If aCtrl.Top >= Me.Height Then
                    aCtrl.Top = 0 - aCtrl.Height
                Else
                    aCtrl.Top = aCtrl.Top + Speed
                End If
        End Select
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Marquee(Label1, 0, 3)
    End Sub

No comments:

Post a Comment