Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleDraw samples of hatch patterns in Visual Basic 6
DescriptionThis example shows how to draw samples of hatch patterns in Visual Basic 6.
KeywordsFillStyle, hatch, hatch pattern, Visual Basic, graphics
CategoriesGraphics
 
To fill an area with a hatch pattern in Visual Basic 6, set the drawing object's FillStyle to one of the defined FillStyleConstants values. Then draw the shape.

Subroutine DrawSample draws and labels a sample hatch pattern.

 
Private Sub DrawSample(ByRef X As Single, ByRef Y As _
    Single, ByVal fill_style As FillStyleConstants, ByVal _
    txt As String)
Const WID As Single = 1440 * 2
Const HGT As Single = 1440 / 2
Const GAP As Single = 120 * 3

    Me.FillStyle = fill_style
    Me.Line (X, Y)-Step(Me.ScaleWidth - 2 * X, HGT), , B

    Y = Y + HGT
    Me.CurrentX = X
    Me.CurrentY = Y
    Me.Print txt
    Y = Y + GAP
End Sub
 
The main program calls DrawSample for each of the defined hatch patterns.
 
Private Sub Form_Paint()
Dim X As Single
Dim Y As Single

    Me.FillColor = vbWhite
    Me.ForeColor = vbBlue

    X = 120
    Y = 120
    DrawSample X, Y, vbCross, "vbCross"
    DrawSample X, Y, vbDiagonalCross, "vbDiagonalCross"
    DrawSample X, Y, vbDownwardDiagonal, _
        "vbDownwardDiagonal"
    DrawSample X, Y, vbFSSolid, "vbFSSolid"
    DrawSample X, Y, vbFSTransparent, "vbFSTransparent"
    DrawSample X, Y, vbHorizontalLine, "vbHorizontalLine"
    DrawSample X, Y, vbUpwardDiagonal, "vbUpwardDiagonal"
    DrawSample X, Y, vbVerticalLine, "vbVerticalLine"
End Sub
 
 
Copyright © 1997-2006 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated