Skip to main content

Obtaining data from drop down combo box

Hey Brian,
This site has become a staple for me. Thanks so much for all your assistance.
I am trying to obtain the selection from a drop down combo box; however, when I select COL1 where the data is to be tested - nothing happens. When I select COL2 then the script continues and completes my test using the COL1 information. Any idea how to fix this or why it is happening?
This is a copy of the code that I am using to obtain the drop down combo box selection.
If dlg.DropListBox1 > 1 Then
userSel = ListBox1$(dlg.DropListBox1)
Else
userSel = ""
End If
Any ideas would be greatly appreciated.
Best Regards,
scox

scox Fri, 10/06/2017 - 11:40

*correction:
If dlg.DropListBox1 > -1 Then
userSel = ListBox1$(dlg.DropListBox1)
Else
userSel = ""
End If
This was the orignal code and I was trying to manipulate it to actually select the 1st column but to no avail.

scox Fri, 10/06/2017 - 13:53

I've opened another file to check it and it seems to have shifted all the columns to the right. COL2 is COL1, COL3 is COL2 etc...
I ammended the code as follows and it now works correctly.
If dlg.DropListBox1 > -1 Then
userSel = ListBox1$(dlg.DropListBox1+1)
Else
userSel = ""
End If
It works now but I don't know the reason for the error.

Brian Element Sun, 10/08/2017 - 08:21

In reply to by scox

Hi scox,

Glad you are finding the site usefule and also that you found your solution.  This is one of the quirks of the dialog box in IDEAScript.  When you created your array you probably started with item 1 as the first field is field 1, then field 2, and so on.  So in your ListBox1$() array item 1 is probably COL1.  The problem is that for the drop-down the first item becomes 0, the second item 1 and so on.  So if your array is starting at 1 you will have to add a one to it.  One way to get around this is when you are building your field array is to start at 0 (subtract a 1).

Hopefully that clears up why this is like it.

Brian

The website encountered an unexpected error. Try again later.