FOR Loop Graphics

These programs use loops to create interesting designs. No controls are placed on the form and no properties are changed. Start a new project or delete the code from the previous exercise.
Look at each example, run it, then make some slight modifications. Experiment!
sea shells
Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
   Handles Me.MouseClick
   Dim Num As Integer
   Dim MyPen As New Pen(Color.Chocolate)
   For Num = 1 To 25 Step 5
       Me.CreateGraphics.DrawEllipse(MyPen, e.X, e.Y, Num, Num)
   Next Num
End Sub 'Form1_MouseClick
 
concentric
Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
   Handles Me.MouseClick
   Dim Num As Integer
   Dim Hlf As Integer
   Dim MyPen As New Pen(Color.DarkMagenta)
   For Num = 2 To 26 Step 4
      Hlf = Num / 2
      Me.CreateGraphics.DrawEllipse(MyPen, e.X - Hlf, e.Y - Hlf, Num, Num)
   Next Num
End Sub 'Form1_MouseClick

INDEX, A Demo loop program, For Loops, Step: change the increment, While Loops, While, cont., Endless loops, Do Loops, Nested Loops, For Each Loops, Graphics with Loops
Next lesson: Arrays in Visual Basic

Copyright © Zebra0.com
All rights reserved worldwide.

 
 

Graphics with Loops