
Advanced Programming Concepts • Chapter 6 249
' Create pen object
3 Dim oPen As New System.Drawing.Pen(system.Drawing.Color.Black)
' Draw up a rectangle
4 grp.DrawRectangle(oPen, 100, 100, 100, 100)
End Sub
In this code fragment, line 1 creates a graphics object.The form in line 2
then instantiates this graphics object. Line 3 creates a pen object to be used for
our drawing.The color should be specified in the parameter list.The output of
the code is shown in Figure 6.6.
As you can see, a rectangle is drawn on the form. If you are familiar with the
drawing techniques in earlier versions of Visual Basic, you will realize quickly that
the code needs to go ...