Skip to main content

How to get drop list box result

Hello Bryan,
I have a problem with my dialog box.
I created one with IDEA script dialog box menu and add an drop list box.
My problem is that I can't mange to know what did the user picked up !
I've search for a solution for a such long time but didn't manged to fix it.
I tried this in my code :
Button = Dialog (Dlg1) ' Dlg1 is the name of my dialog box 
If Button = -1 Then
MsgBox "You selected" & Dlg1.DropListBox & "as the color" 
Else
MsgBox "You clicked Cancel."
End If 
Could you help me ?

klmi Fri, 07/10/2020 - 09:29

Due to your short snippet I don't know what works and what not with your code. The following code example works fine for me. Please compare it with your full code (f.e. use a text editor - not IDEAScript editor - to see the code including dialog section) and the preferences in the dialog editor.


Begin Dialog Sample_Dialog 20,40,200,100,"Dialogbox"
DropListBox 5,5,50,50, sColors(), .DropListBoxSelection
OKButton 25,60,40,14
CancelButton 130,60,40,14
End Dialog

Sub Main
Dim sColors() As String
ReDim sColors(3)
sColors(0) = "red"
sColors(1) = "blue"
sColors(2) = "green"
sColors(3) = "yellow"
Dim Dlg1 As Sample_Dialog
Button = Dialog (Dlg1)
If Button = -1 Then
MsgBox "You selected " & Dlg1.DropListBoxSelection & " as the color"
Else
MsgBox "You clicked Cancel"
End If
End Sub

Hugo Lucciano Mon, 07/13/2020 - 03:04

Hello klmi
Thanks for your awnser ! My problem is that I can't create a dialog box with Begin Dialog, Idea Script just delete it so I must use the dialog box editor. Therefore I can't add .DropListSelection to get it !! That's my problem. And when I write Dlg1.DropListBoxSelction, an error appears in the compilation.

klmi Mon, 07/13/2020 - 03:17

In reply to by Hugo Lucciano

When you use the IDEAScript editor you can't see the code of the dialog because you have to use the dialog editor. But if you open your script f.e. in notepad the code of the dialog is shown.

The website encountered an unexpected error. Try again later.