Convert a section of a VI into a subVI by using the Positioning tool to select the section of the block diagram you want to reuse and selecting Edit»Create SubVI. An icon for the new subVI replaces the selected section of the block diagram. LabVIEW creates controls and indicators for the new subVI and wires the subVI to the existing wires.
Creating a subVI from a selection is convenient but still requires careful planning to create a logical hierarchy of VIs. Consider which objects to include in the selection and avoid changing the functionality of the original or resulting VI.
Consider the following issues when you create subVIs from VI selections:
- Creating a subVI from a selection is the same as removing the selected objects and replacing them with a subVI. In both situations, LabVIEW does the following:
- LabVIEW does not remove any of the front panel terminals included in the selection from the original VI. The front panel terminals remain on the front panel of the original VI and the terminals are wired to the new subVI.
- For each front panel object with a Property Node or local variable in the selection, LabVIEW adds a control reference to the original block diagram and wires the reference to the subVI. In the subVI, LabVIEW wires the reference to a Property Node.
- Do not select more than 28 objects to create a subVI because 28 is the maximum number of connections on a connector pane.
- Avoid creating cycles on the block diagram.
- Avoid including a structure that contains a front panel terminal in the selection.