Example Code

Convert Integer to Enum

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

Coding that exemplifies how to convert an integer into an enum.

 

Description

This example shows two methods of converting an integer to its enum equivalent. The first method uses the Variant to Data VI and the second uses typecasting.

 

Requirements

LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code
1. Insert a number in the numeric control within the enum amount of items
2. If desired, change the items of the Reference Enum.
3. Run the VI, and observe the Enum indicators.

 

Additional Information or References

Snippet.png

Tanya Visser
National Instruments
LabVIEW Group Manager

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

Comments
Eric_BOB
Member
Member
on

Hi your exempl is wrong for type cast convertion, it's a U16 and not U32 who run.

Stefan.Cals
Member
Member
on

For method 2: you should look at the Representation (U32, U16 or U8 for enums) of your enum and use that before the type cast