Jumat, 13 Desember 2024

vb6 text scroll from bottom to top 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 = 5 ' Set the timer interval (milliseconds)

    Timer1.Enabled = False

    textPos = Me.ScaleHeight

    Label1.Top = 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 up

        textPos = textPos - 5

        If textPos < -Label1.Height Then

            ' Reset the text position when it goes off screen

            textPos = Me.ScaleHeight

        End If

        Label1.Top = textPos

    End If

End Sub


Tidak ada komentar: