Example Code

Programmatically Set Range of Controls

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 code utilizes the property nodes of a slide control to programmatically change its maximum and minimum values.

  

Description

This code takes advantage of the property node of a control and the features that can be updated at runtime. The user has the opportunity to manipulate the maximum and minimum values of the control on the front panel with user defined inputs. This property can be used to make sure a control being used as an input to another program is providing inputs within a needed range.

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Enter in any value for the maximum in the Data Entry Limits:Maximum control
  2. Enter in any value less than the maximum value into the Data Entry Limits:Minimum control
  3. Dial any value on  Dial on the front panel (This will effectively send its value to the slider)
  4. Run the VI 

 

Additional Information or References

 

Front Panel

3.PNG

 

VI Snippet

2.png

 

 

 

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

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

Comments
stacey54
Member
Member
on

I would like to set limits to data entry in a control.  It appears to me that this vi does not actually use the data entry max min, it really only uses the slider scale max min.  For example, if you remove the slider scale max min, there is no change to the slide indicator or control values.

 

What is an appropriate way to limit user interface values on a control to a specified range?Slider Max Min VI with Scale Max Min RemovedSlider Max Min VI with Scale Max Min Removed

stacey54
Member
Member
on

 On further examination, what I wanted to control on data entry was the dial, not the slider.  The snippet below performs to my expectations.  Additionally, the control properties must be changed such that data entry is coerced.

Data Entry Limits on Dial ControlData Entry Limits on Dial Control