Controlling Repetitive Operations Using Loops
- Updated2026-09-28
- 2 minute(s) read
Use the For loop and the While loop to repeat blocks of code or operations on the block diagram.
Note If you open a refnum inside a
For loop or While loop, close that refnum for each
iteration of the loop. Otherwise, LabVIEW repeatedly allocates memory for the refnum and
does not free the memory until the VI finishes running.
Related Information
- For Loops: Repeating Operations a Set Number of Times
You can use a For Loop to execute a section of code contained within the loop, called a subdiagram, a set number of times.
- While Loops: Repeating Operations Until a Condition Occurs
Similar to a Do Loop or a Repeat-Until Loop in text-based programming languages, a While Loop executes a subdiagram until a condition occurs.
- Refnum Controls and Indicators
Use the reference number controls on the Refnum palette to work with files, directories, devices, and network connections in your VIs.
- Specifying the Number of Times Operations in For Loops Execute
- Specifying Conditions for While Loops
- Processing Individual Elements in an Array or a Collection with a Loop
- Handling Errors Using Conditional Terminals on Loops
- Transferring Values between Loop Iterations
You can use shift registers, error registers, and the Feedback Node in LabVIEW to transfer values between loop iterations for For loops, While loops, or (Real-Time, Windows) Timed Loops.
- Configuring Settings of a Timed Structure (Real-Time, Windows)