Jumat, 13 Desember 2024

vb6 text scroll animation with button code

 



Option Explicit


Private scrolling As Boolean

Private textPos As Integer


Private Sub Form_Load()

    Label1.Caption = "Welcome to the VB6 Text Scrolling Animation!"

    Label1.AutoSize = True

    Command1.Caption = "Play"

    Command2.Caption = "Stop"

    Timer1.Interval = 50 ' Set the timer interval (milliseconds)

    Timer1.Enabled = False

    textPos = Me.ScaleWidth

    Label1.Left = textPos

End Sub


Private Sub Command1_Click()

    ' Start the scrolling animation

    scrolling = True

    Timer1.Enabled = True

End Sub


Private Sub Command2_Click()

    ' Stop the scrolling animation

    scrolling = False

    Timer1.Enabled = False

End Sub


Private Sub Timer1_Timer()

    If scrolling Then

        ' Move the text to the left

        textPos = textPos - 5

        If textPos < -Label1.Width Then

            ' Reset the text position when it goes off screen

            textPos = Me.ScaleWidth

        End If

        Label1.Left = textPos

    End If

End Sub


Tidak ada komentar: