How to get drop list box result

7 posts / 0 new
Last post
Hugo Lucciano
Offline
Joined: 07/09/2020 - 10:04
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
Offline
Joined: 02/13/2019 - 08:41

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
Offline
Joined: 07/09/2020 - 10: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
Offline
Joined: 02/13/2019 - 08:41

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.

Hugo Lucciano
Offline
Joined: 07/09/2020 - 10:04

So I can't use the Drop List Box in IDEA Script Editor ?

klmi
Offline
Joined: 02/13/2019 - 08:41

No you can! I assume that you didn't set the right properties in the script editor. I hope you will find out what's wrong if you compare the codes / the properties in the dialog editor.

Hugo Lucciano
Offline
Joined: 07/09/2020 - 10:04

Thanks you very much for your help, I finally managed to figure out what was going on