Creating Global Variables
- Updated2026-08-28
- 3 minute(s) read
Global variables share data among multiple VIs. To create a global variable, add a global variable object to the block diagram and modify the global VI for the global variable. Then, associate the global variable with front panel objects.
Global variables operate outside of the dataflow paradigm that LabVIEW uses. Before creating global variables, understand when to use global variables and performance considerations for global variables.
You can use different approaches to create global variables:
- Create several single-object global VIs with one front panel object each
- Group similar variables together: create one global VI that contains multiple front panel objects
In general, creating global variables involves two steps:
- Create the global VI.
- Add the global variable to the block diagram of a VI and assign the global variable to front panel objects of the VI.
Creating a New Global Variable
To define the data that a global variable shares, create the global VI for the global variable and add front panel objects to it. Then, associate the global variable with the objects that you want to use the global variable.
To create a global VI for a global variable and associate the global variable with front panel objects, complete the following steps.
-
Add a global variable
(
) to the block diagram from the Functions palette and place it on the
block diagram.
-
Use the Operating tool or Positioning tool to double-click the global variable
node.
The front panel window of the global VI for the global variable opens.
-
Add one or more controls or indicators to the front panel window the same way
you do in a standard front panel window.
Tip LabVIEW uses owned labels to identify global variables. Label the front panel controls and indicators with descriptive owned labels.The controls and indicators that you add to the global VI define the data that the global variable shares among VIs.
-
Save and close the global VI.
Tip Remember where you save the global VI. To associate other VIs with a global variable, you add the global variable to the block diagram from this file location.
-
Return to the block diagram of the original VI and associate the global
variable with front panel objects.
- Right-click the global variable node and select
a front panel object from the Select Item shortcut
menu.
The shortcut menu lists all the front panel objects that have owned labels.
- Use the Operating tool or Labeling tool to click the global variable node and select the front panel object from the shortcut menu.
- Right-click the global variable node and select
a front panel object from the Select Item shortcut
menu.
If you create a copy of a global variable node, LabVIEW associates the new global variable node with the global VI of the variable node you copy it from.
Integrating an Existing Global Variable Into a VI
To integrate an existing global variable into a VI, complete the following steps.
- On the Functions palette, click the Select a VI icon or text, navigate to the folder where you saved the global VI, and double-click the VI.
-
Add the global variable to the block diagram.
By default, the global variable is associated with the first front panel object with an owned label you added to the global VI.
-
Associate the global variable with the data from another front panel
object.
- Right-click the global variable node you added to the block diagram.
- Select the front panel object to associate with the global variable from the Select Item shortcut menu.
Related Information
- Data Communication Methods in LabVIEW
LabVIEW contains many data communication methods, each suited for a certain use case. Refer to the overview to ensure you implement the correct data communication method for your application.
- Using Local Variables and Global Variables Carefully
Local variables and global variables are advanced LabVIEW concepts that exist outside of the dataflow paradigm in LabVIEW. As a result, consider the implications of using local variables and global variables instead of dataflow programming in LabVIEW.
- Memory Considerations when Using Global Variables
When you read from a global variable, LabVIEW creates a copy of the data stored in that global variable.