Solved: listbox selection set to match a text string

I am trying to select a listbox entry so that it matches an array value. This is in a search routine so that if the text in TextBox1 matches the search criterion [in this case, SearchArray(zzz, 4)], then the selected value, in text, not index number, of ListBox1 matches the string value of SearchArray(zzz, 5).

If oDialog1.getControl(“TextBoxx1”).Text = SearchArray(zzz, 4) Then

oDialog1.getControl(“ListBox1”).??? = SearchArray(zzz, 5)

End If

What might replace the question marks?

Thanks in Advance.

@hvankampen: In the future, please do not post as community wiki. Also, if my answer does not work, then please provide a few more details about the code and a complete example. See guidelines for asking.

XListBox.selectItem() should do the trick. Based on the code snippet in the question, try this:

oDialog1.getControl("ListBox1").selectItem(SearchArray(zzz, 5))

For a more robust solution, here is some code in Python which you can adapt for Basic.

if listCtrl.supportsService(""):
    if selectedValue and selectedValue in values:
        listCtrl.selectItem(selectedValue, True)
        listCtrl.selectItemPos(0, True)
elif listCtrl.supportsService(""):
    if selectedValue and selectedValue in values:

Thank you for your help. I thought it had to be something like this. The trouble was actually being caused by another part of the code. The final result was:

oDialog1.getControl(“ListBox1”).selectItem(SearchArray(zzz, 5), true)