VB.NET - How To Make Animation Images (ImagesList VS PictureBox)


VB.NET - How To Make Animation Images (ImagesList VS PictureBox) *VB 2010*

🎓 Master Visual Basic .NET and Access Database By Building the Point Of Sale System (POS).
ðŸ“ē Enroll Now: https://bit.ly/2WcbRhX

[Source Code]

Public Class Form1
    Private idx As Integer = 0
    Private x As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        x = Me.Width
        Timer1.Interval = 150
        TextBox1.Text = 150
        TextBox1.Enabled = False
        btnStart.Select()
        Label1.Cursor = Cursors.Hand
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If idx = ImageList1.Images.Count Then
            idx = 0
        End If
        If x > Me.Width Then
            x = -PictureBox1.Width
        End If
        PictureBox1.Image = ImageList1.Images(idx)
        PictureBox1.Left = x
        idx += 1
        x += 8
End Sub

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.Checked = True Then
            TextBox1.Enabled = True
        Else
            Timer1.Interval = 150
            TextBox1.Text = 150
            TextBox1.Enabled = False
        End If
End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        If (TextBox1.Text = "") Then
            Exit Sub
        ElseIf Not IsNumeric(TextBox1.Text) OrElse (TextBox1.Text) <= 0 Then
            MsgBox("PLEASE ENTER ONLY NUMBERS!", MsgBoxStyle.Information, "Info! only numbers and 0 not allowed")
            TextBox1.Text = ""
            Exit Sub
        Else
            Timer1.Interval = (TextBox1.Text)
        End If
End Sub

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
        CheckBox1.Checked = False
End Sub

Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles btnStart.Click, btnPause.Click, btnStop.Click
        Dim btn As Button = CType(sender, Button)
        Dim slc As String = btn.Text
        Select Case slc
            Case "Start"
                Timer1.Start()
            Case "Pause"
                Timer1.Stop()
            Case "Stop"
                Timer1.Stop()
                x = Me.Width
                PictureBox1.Left = x
        End Select
End Sub
End Class


Thank you very much.
āļ‚āļ­āļšāļ„ุāļ“āļ„āļĢัāļš.

Comments