Initialize Method

NI Vision for Visual Basic

Initialize Method

Syntax

CWIMAQRectangle.Initialize Left, Top, Width, Height

Purpose

Sets all the properties of the rectangle with one method call.

Parameters

Left As Single

The left of the rectangle.

Top As Single

The top of the rectangle.

Width As Single

The width of the rectangle.

Height As Single

The height of the rectangle.

Example

Private Sub Run_Click()
    Dim Rectangle1 As New CWIMAQRectangle
    Dim Rectangle2 As New CWIMAQRectangle
    
    'Initialize the first rectangle
    Rectangle1.Initialize 3, 23, 19, 81
    
    'Copy the properties from the first rectangle into the second rectangle
    Rectangle1.CopyTo Rectangle2
    
    'Move the first rectangle. This move does not affect the second rectangle
    Rectangle1.Left = Rectangle1.Left + 70
    Rectangle1.Top = Rectangle1.Top + 70
    
    'Add the rectangles to the viewer's regions collection.
    CWIMAQViewer1.Regions.AddRectangle Rectangle1
    CWIMAQViewer1.Regions.AddRectangle Rectangle2
End Sub