Page 1 of 1

Instruments-Panel: Getting Ordinal of Enum from Value-Edit in VbsMacro

Posted: Thu 23. May 2024, 17:51
by scope
Hello Marvin!
Hope you are doing well!

Is ther a way i can get the Index of a selected value in a Value Edit that is connected to a signal with an ENUM?

Code: Select all

Dim panel, temp
Set panel = Documents("HMI-Internal_CAN.ipf").ActiveWindow.Object
Set temp = panel.Scenes(1).Controls("ve1")
'''''''''' here i want to read the index of the selected choice of the Value Edit
Thanks

Re: Instruments-Panel: Getting Ordinal of Enum from Value-Edit in VbsMacro

Posted: Fri 24. May 2024, 10:36
by M.Heidemann
Hey Scope,

Please create a new topic if your questions is unrelated to the original topic,
this is alot easier to search for other users.

I created a new topic from your response.

I extended your code to show how you can get the ordinal of the enum contained
in the signal assigned to your Value-Edit:

Code: Select all

Sub GetValueEditEnumOrdinal()

Dim panel, temp, assignedenum, index, tempval
Set panel = Documents("HMI-Internal_CAN.ipf").ActiveWindow.Object
Set temp = panel.Scenes(1).Controls("ve1")
set assignedenum = temp.Signal.Enum
tempval = temp.Value
index = assignedenum.FindOrdinal(tempval)

PrintToOutputWindow index

End Sub
As you can see, i use the current value of the Value-Edit to get the Ordinal via ENUM.FindOrdinal