ListBox, ComboBox, Drop-Down List

  • Filter
  • Time
  • Show
Clear All
new posts

  • ListBox, ComboBox, Drop-Down List

    I've worked out that how to create a drop-down list using the following code which was given in PCDMIS help file for sample and it works fine

    After execution of the script, The combo-box plays well, it returns the text which i selected from the list, but
    The list-box and the drop-down List is returning the position of the selected text from the list ...............

    can someone help me that how to retrieve the item From the list for listbox & dropdown list............

    Sub Main
    Dim MyList$ (5)
    MyList (0) = "AAA"
    MyList (1) = "BBB"
    MyList (2) = "CCC"
    MyList (3) = "DDD"
    MyList (4) = "EEE"
    MyList (5) = "FFF"
    Begin Dialog BoxSample 16,35,256,89,"List Box, Combo Box, and Drop-Down List Box"
        OKButton 204,24,40,14
        CancelButton 204,44,40,14
        ListBox 12,24,48,40, MyList$( ),.Lstbox
        DropListBox 124,24,72,40, MyList$( ),.DrpList
        ComboBox 68,24,48,40, MyList$( ),.CmboBox
        Text 12,12,32,8,"List Box:"
        Text 124,12,68,8,"Drop-Down List Box:"
        Text 68,12,44,8,"Combo Box:"
    End Dialog
    Dim Dlg1 As BoxSample
    Button = Dialog ( Dlg1 )
    Chklist = Dlg1.Lstbox
    Chkcombo = Dlg1.CmboBox
    ChkDrop = Dlg1.DrpList
    MsgBox (Chklist)
    MsgBox (Chkcombo)
    MsgBox (Chkdrop)
    End Sub

  • #2
    Why not just use the index into MyList$ ? As the ListBox and DropListbox don't allow free entry of text, the choice will always match a position in the array.

    MsgBox (MyList$(Chklist))
    MsgBox (Chkcombo)
    MsgBox (MyList$(Chkdrop))
    Last edited by AndersI; 09-04-2019, 06:56 AM.
    SW support - Hexagon Metrology Nordic AB


    • #3
      I'd check out forms if I were you. Much easier to work with than custom dialogs.
      Automettech - Automated Metrology Technology


      • NinjaBadger
        NinjaBadger commented
        Editing a comment
        You need to use:

        PARAM/Combobox1.TEXTVALUE=V1 (or V1=Combobox1.TEXTVALUE - can't remember which way round it is) to get the value of a combo box back to an assignment.

      • Ego Murphy
        Ego Murphy commented
        Editing a comment

        The User Interface for Forms is just awful:
        1) Insert form call. A blank line appears: PARAM/=
        2) Use your magnifying glass to carefully click your cursor into the 2-pixel wide blank between the / and the =
        3) Laboriously type in the full exact name of the item on the form, then .TEXT for text input or .VALUE for numerical input.
        4) Carefully hit the Tab key exactly once to skip cursor focus to the right of the =
        5) Laboriously type in the name of the already-existing variable in your PRG that you want the junk to dump into.
        6) After you click out, a new blank PARAM/= appears below. Repeat.

        Seriously, no dialog interface whatsoever - just tribal knowledge of a painful and not-at-all-obvious interface.

        7) * Bonus ability: if you assign the variable a value before the Form is called, that value will be displayed as the Default in the Form when it runs. I'm pretty sure everyone in a certain factory is still using "Bob" as the inspector name for every CMM run... even though Bob retired. *

      • anthony.alfaro
        anthony.alfaro commented
        Editing a comment
        There's a "tutorial" in the help file on building a custom form. While's it complete or exhaustive, with enough brain power and context clues you can build a successful form. I did for my programs.

    Related Topics