I wanted to collect all unique values in a column and show it in multilist box.

  • Welcome to GIS SE! To encourage someone to answer your question I recommend that you edit it to add more details like what MapInfo Professional version you are using and what your code (just a snippet) related to this looks like so far. – PolyGeo Nov 27 '13 at 22:06
include "mapbasic.def"
include "menu.def"
include "icons.def"

Declare Sub Main
Declare Sub OKButton
Declare Sub CancelButton

' ==========================
Sub Main

    Dim i as integer
    Dim ColValue As Alias
    Dim s_ColValues(50) as String

' - Query your table and group wanted column (list of unique values)
    Select YOUR_COLUMN from YOUR_TABLE group by YOUR_COLUMN into UNIQUE_values

' - Populate array with all unique values (from first column in UNIQUE_values table)
    For i = 1 to SelectionInfo(SEL_INFO_NROWS)         
        ReDim s_ColValues(i)
        Fetch rec i From UNIQUE_values
        ColValue = UNIQUE_values + ".col1"
        s_ColValues(i) = ColValue

' - Now make some dialog and in MultiListBox control set 'TITLE From Variable' and name of array variable (s_ColValues)

     POSITION 205, 150
        WIDTH 90 HEIGHT 130
        TITLE "Select Value"
        CONTROL MultiListBox
          POSITION 3, 25
          WIDTH 80 HEIGHT 60
          ID 2
          TITLE from variable s_ColValues
        CONTROL OKButton
          POSITION 45, 90
          WIDTH 38 HEIGHT 14
          TITLE "OK"
          CALLING OKButton
        CONTROL CancelButton
          POSITION 5, 90
          WIDTH 38 HEIGHT 14
          TITLE "Cancel"
          CALLING CancelButton
End Sub

Sub OKButton
End Sub

Sub CancelButton
End Sub
' ==========================
  • 1
    If the answer work for you: you can vote and "accepted" the answer (click the grey checkmark at the left side of the answer). Thanks. – sys49152 Nov 28 '13 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.