The following VBA example creates a pattern on a new 64 × 64 bitmap and adds it to the list of available two-color fills. It then applies the fill pattern to a newly created rectangle.
Sub Test()
Dim c As New PatternCanvas
Dim n As Long
c.Size = cdrPatternCanvas64x64
c.Clear
For n = 2 To 63 Step 2
c.Line (0, 0)-(n, n), , B
Next n
On Error Resume Next ' The code in green is a workaround.
n = PatternCanvases.Add(c)
If Err.Number Then n = PatternCanvases.Add(c)
On Error GoTo 0
With ActiveLayer.CreateRectangle(0, 0, 3, 3)
.Fill.ApplyPatternFill cdrTwoColorPattern, , n
End With
End Sub