Public Class Form1 Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll Dim c1, c2, numberOfBoxes, numberOfRows As Integer Dim paper As Graphics Dim myPen As Pen = New Pen(Color.Blue, 2) numberOfBoxes = TrackBar1.Value numberOfRows = TrackBar2.Maximum - TrackBar2.Value paper = PictureBox1.CreateGraphics() paper.Clear(Color.Gold) For c2 = 1 To numberOfRows For c1 = 1 To numberOfBoxes paper.DrawRectangle(myPen, 20 * c1 - 10, 20 * c2 - 10, 12, 12) Next Next End Sub Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub TrackBar2_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar2.Scroll Dim c1, c2, numberOfBoxes, numberOfRows As Integer Dim paper As Graphics Dim myPen As Pen = New Pen(Color.Blue, 2) numberOfBoxes = TrackBar1.Value numberOfRows = TrackBar2.Maximum - TrackBar2.Value paper = PictureBox1.CreateGraphics() paper.Clear(Color.Gold) For c2 = 1 To numberOfRows For c1 = 1 To numberOfBoxes paper.DrawRectangle(myPen, 20 * c1 - 10, 20 * c2 - 10, 12, 12) Next Next End Sub End Class