How to get drop list box result
Forums
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 ?
Hello klmi
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.
Due to your short snippet I
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