Hi!
Can someone please explain to me why this code doesn't work? Most of the description is in the comments of the code, but what I'm looking for is how to make the points move?
Thanks in advance as always!
P.S. How can I change the color in these code blocks? ^ I prefer the regular VB 2010 colors.vb Code:
Public Class Form1 Dim R As New Random Dim PtList As New List(Of Point) Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load 'Start timer and create 300 random points in a 200x200 rectangle. Timer1.Start() For i As Int32 = 0 To 300 Step 1 PtList.Add(New Point(R.Next(0, 200), R.Next(0, 200))) Next End Sub Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint 'Draw each point. Dim G As Graphics = e.Graphics For Each Point In PtList G.FillRectangle(Brushes.Black, Point.X, Point.Y, 1, 1) Next End Sub Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick 'Create a temporary point, subtract a portion, and thus resetting each point's location. 'This should make each point move back and up 5 pixels per tick. Dim NextPoint As New Point(20, 20) For Each Point In PtList Point.X -= CInt(NextPoint.X / 4) Point.Y -= CInt(NextPoint.Y / 4) Next 'I have this code here just to make sure the timer is working correctly. Static a As Int32 = 0 a += 1 Me.Text = a Me.Invalidate() End Sub End Class




Reply With Quote
