AddRegion Method

NI Vision for Visual Basic

AddRegion Method

Syntax

CWIMAQRegions.AddRegion Region

Return Type

CWIMAQRegion

The region object that was added. This region is not the same as the input region.

Purpose

Adds a region that contains any type of shape to the regions collection.

Remarks

This method makes a copy of the input region.

Parameters

Region As CWIMAQRegion

The region to add.

Example

Private Sub Run_Click()
    'Copy the first region in the regions collection
    CWIMAQViewer1.Regions.AddRegion CWIMAQViewer1.Regions(1)
    
    'Move the first region in the regions collection
    CWIMAQViewer1.Regions(1).Move 50, 50

     'Add the region to the viewer's regions collection.
    CWIMAQViewer1.Regions.AddRegion Region

    If TypeName(Region) = "Nothing" Then
    MsgBox "Number of regions exceeded!"
    Else
    MsgBox "You added a region." 
    End If

End Sub