The first obvious drawing function is Line, which uses this syntax:
Printer.Line [Step] (x1, y1) [Step] - (x2, y2), [color], [B][F]
That might look at bit odd at the moment, so lets take a look. First of all,
the (x1, y1)
parameter tells VB the coordinates where you want
the line to start. And so, the (x2, y2)
parameter tells VB the
coordinates where you want the line to end. The brackets surrounding the word
'Step' means that it is optional - you don't have to include it. If you include
the first step (without the brackets), VB will draw the line relative
to the CurrentX and CurrentY properties. This means, that if you passed Step
(4,8)
instead of the line starting 4 pixels (or whatever DrawMode you
are in) from the left of the page, and 8 pixels from the top, it will draw the
line 4 pixels to the right of CurrentX, and 8 pixels below CurrentY. Essentially,
Printer.Line Step (x1, y1)
is the same as
Printer.Line (x1 + Printer.CurrentX, y1 + Printer.CurrentY)
The final parameter specifies the colour of the line. The B
and
F
options provide two more options. If B is specified, then VB
will treat the second set of coordinates as the position of the bottom right
hand corner of a box, and draw the box for you. If you use the B option, you
can also give the F option, which means the box will be filled, using the graphic
options described later.
Lets take a look at a few examples.
Printer.Line (1000, 2000)-(5000, 3000), vbRed
Printer.EndDoc
This code draws something like this:
Using the a combination of Line statements, and the Step keyword, we can also draw a box:
Printer.Line (1000, 2000)-(5000, 2000), vbRed
'Draw down from end of first line
'don't change X pos
'change Y pos by 4000
Printer.Line Step(0, 0)-Step(0, 2000), vbRed
'draw across 'change X pos by -4000
'don't change Y pos
Printer.Line Step(0, 0)-Step(-4000, 0), vbRed
'draw up
'don't change X pos
'change Y pos by -4000
Printer.Line Step(0, 0)-Step(0, -2000), vbRed
Printer.EndDoc
Of course, using the B statement, we can draw a box far more easily using the following code:
Printer.Line (1000, 2000)-(5000, 4000), vbRed, B
Printer.EndDoc
Comments