DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Listbox get items to script

Hello,

how can i transfer the items (names) of a listbox to script.

Thanks

0 Kudos
Message 1 of 5
(4,915 Views)

Hi AndiMEC,

 

Do you mean a listbox control in a SUDialog?

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 5
(4,903 Views)

Hi Brad

i have a dialog with a listbox and a (channel)combobox from which i add any number of channels to the listbox. Now i need to get all the items(Channels) which are in the listbox to my script for further analysis.

0 Kudos
Message 3 of 5
(4,896 Views)

Hi,

 

just add all Elements to an Array or Dictionary and give this Oject to your Script:

 

In your SUD:

Dim aTmp()

  Redim aTmp(listBox.Items.Count - 1)
  
  For i = LBound(aTmp) To UBound(aTmp)
    aTmp(i) = listBox.Items(i+1).Text
  Next

  Call Dialog.SetArgument(aTmp)

 

Now in your VBS:

Dim i, aChannels

If (SUDDlgShow("name", sPathToSUD, aChannels) = "IDOk") Then
  For i = LBound(aChannels) To UBound(aChannels))
    Call LogFileWrite(aChannels(i))
  Next
End If

 

 

 

0 Kudos
Message 4 of 5
(4,880 Views)

Hi AndiMEC,

 

Execute this code in the SUDialog and pass the ChanNames variable back to the calling VBScript.  You may probably have to change the name of the control from "ChnCombobox1" to whatever you called it.

 

  Dim i, iMax
  iMax = ChnComboBox1.Items.Count
  ReDim ChanNames(iMax)
  FOR i = 1 TO iMax
    ChanNames(i) = ChnCombobox1.Items(i).Text
  NEXT ' i
  MsgBox Join(ChanNames, vbCRLF)

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 5 of 5
(4,858 Views)