問題:我有一個輸入框,讓用戶只能從規(guī)定列表中選取值輸入,那么我就要用enum,但是enum輸出的值是它的value,value永遠都是從0開始的遞增數,我才不想要這個數值,我想要用戶在列表中選取的的那個數值。
精簡:即獲取enum中的item值,而不是value。
思路:獲取到item列表(string類型),用value去index這個列表,再轉換為數值
Method 1: Property Node with an Enum Control
If an enum control or indicator exists, create a property node for the enum and select the Strings[] property. This property returns an array of strings for the specified enum. Then use the Index Array function with the enum wired to the index terminal to access the desired string.
Method 2: Format Into String
If there is no enum control or indicator in the VI, wire the enum to the Format Into String function input; with a string value of %s wired to the format string input. This function returns the string value associated with the input enum value.
兩種方法都畫在下面

image.png