Hello! I was working on a screen saver that creates rectangles that start from the center of the screen and expand as they move to the edge of the screen. It was working just fine for a little while, and I'm not sure what I did but now, when I load the form, nothing appears. Can someone please help? Thank you!
vb Code:
Public Class Form1 Dim R As New Random Dim R1 As New Rectangle Dim Cs As New Size Dim Distance As New Decimal Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Me.DoubleBuffered = True NewRectangle() Timer1.Start() End Sub Private Sub NewRectangle() Distance = 0 Cs = ClientSize R1.Width = R.Next((Cs.Width * 0.1), (Cs.Width * 0.5)) R1.X = R.Next(-2 * Cs.Width, Cs.Width) R1.Height = R.Next((Cs.Height * 0.1), (Cs.Height * 0.5)) R1.Y = R.Next((Cs.Height * 0.1), (Cs.Height * 0.5)) End Sub Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) e.Graphics.FillRectangle(Brushes.Blue, New Rectangle((R1.X * Distance + Cs.Width * 0.5), (R1.Y * Distance + Cs.Height * 0.5), (R1.Width * Distance), (R1.Height * Distance))) End Sub Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick Distance = (Distance + 0.1) If Distance > 2 Then Distance = 0 NewRectangle() End If Me.Invalidate() End Sub End Class
