Example Code

Handling Events Generated in a SubVI Using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This VI demonstrates how to handle events that are generated in a subVI

 

Description

If you are familiar with handling user interface events by using the event structure in the same VI, this VI shows how to handle events that are generated in a subVI. Sometimes we want to have the ability to handle events that are generated in a subVI, one or more, in a way that enables the Main VI responding to different types of events , from a different types of resources. This VI shows how to implement such application.

 

Requirements

LabVIEW 2012 (or compatible)

 

Steps to Complete

  1. Open the code and run the main VI. A sub VI will pop up. 
  2. Click the "Clicky" button, and observe that both the sub VI front panel, and the main VI front panel are being updated with the number of clicks.
  3. You can dynamically register for events if you have the reference for the control or for the user event that you want to register. 
  4. Because we can get control references to controls in any VI, we can register for events in any VI.  You can then use the event structure in the main VI to handle it. 

 

Additional Information or References

VI Block Diagram

 

Handling Events Generated in a SubVI LV2012 NI Verified BD1.jpg

 

 

Handling Events Generated in a SubVI LV2012 NI Verified BD2.jpg

 

**This document has been updated to meet the current required format for the NI Code Exchange. **

 

Wes Pierce
Principal Engineer
Pierce Controls

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
crewx
Member
Member
on

This doesn't seem to work, there is also no documentation in the vi explaining what is going on, or what is supposed to happen.

Fail

JW
Wes_P
Member
Member
on

Hi crewx,

Please take a look at this again.  The wrong version of the code got uploaded by accident the first time around.

Wes Pierce
Principal Engineer
Pierce Controls