I have an animation program which allows users to import and animate images. I do this using timer events. I have a listbox which contains the image references, and a Image which displays the chosen image. Here is the code:
When the user clicks the "Animate" button:
vb.net Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles animate.Click Dim cananimate As Boolean = True 'The secret code If Images.Items.Count > 0 Then Images.SelectedIndex = 0 'While it has a image in front, keep animating If Not Images.SelectedIndex = Images.Items.Count - 1 Then Timer1.Start() 'If only one image present, display a message If Images.Items.Count = 1 Then MessageBox.Show("You must have more than one image to begin animating.") End If End If End If End Sub
Timer tick event:
vb.net Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If Not Images.SelectedIndex = Images.Items.Count - 1 Then Cursor = Cursors.AppStarting Images.SelectedIndex += 1 mainimage.Refresh() Cursor = Cursors.Default If Images.SelectedIndex + 1 = Images.Items.Count Then Timer1.Enabled = False End If End If End Sub
I want to make a dialog to appear and allow the user to select a custom FPS for the animation. For instance, if they type 15, the listbox must go down 15 images in 1 second. But how do I convert FPS to a timer interval?![]()


Reply With Quote
