labview 中獲取enum中的item信息,not value

問題:我有一個輸入框,讓用戶只能從規(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
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容