Sara I asked a similar question a few weeks ago and received an example that worked perfectly from Peter Zyczynski. My question was in regards to reading what was selected and putting this into a string to be used in an SQL query. I have copied the reply I received. The key is to use an the ReadControlValue within an OK Handler. I hope this puts you on the right track.
Take care, Aaron ----Peter's reply------- Hi Aaron, The trick is to use a handler for the OK button on your form. In there you can examine what the user selected from the MultiListBox, and build the SQL string. I'm using the value returned by ReadControlValue() as the index for the gs_ZipCodes() array, thereby giving me the value. Try this example: '--------------------------------------------------------------------------- -- Define QT Chr$(34) 'Double quote Global gs_ZipCodes(6) as string Declare Sub Main Declare Sub AskForZipcode Declare Sub OKhandler '--------------------------------------------------------------------------- -- Sub Main 'Set some dummy data. gs_ZipCodes(1) = "1111" gs_ZipCodes(2) = "2222" gs_ZipCodes(3) = "3333" gs_ZipCodes(4) = "4444" gs_ZipCodes(5) = "5555" gs_ZipCodes(6) = "6666" Call AskForZipcode End Sub '--------------------------------------------------------------------------- -- Sub AskForZipcode Dim s_Any, s_SQL as string, i as integer 'Bring up the dialog. Dialog Title "Select zip codes:" Control MultiListBox ID 1001 Title From Variable gs_ZipCodes Width 80 Height 100 Control OKButton Calling OKhandler Control CancelButton End Sub '--------------------------------------------------------------------------- -- Sub OKhandler Dim s_Any, s_SQL as string, i as integer 'Build the "Any" part of the SQL statement. s_Any = "" do i = ReadControlValue(1001) if i < 1 then exit do else s_Any = s_Any + QT + gs_ZipCodes(i) + QT + "," end if loop 'Ensure the user selected at least one zip code. If s_Any <> "" then 'Chop off the unwanted trailing comma. s_Any = Left$(s_Any, Len(s_Any) - 1) 'Build the whole SQL statement. s_SQL = "Select * From MyTable Where MyZipField = Any(" + s_Any + ")" Note s_SQL Run Command s_SQL end if End Sub '--------------------------------------------------------------------------- -----Original Message----- From: Sara Revell [mailto:[EMAIL PROTECTED]] Sent: Monday, July 08, 2002 8:28 AM To: [EMAIL PROTECTED] Subject: MI-L MultiListBox This is a fairly simple question, but does anyone have an example of how to use a MultiListBox in conjunction with ReadControlValue? The reference guide mentions it, but does not provide an example. I have searched all the sample files included with MapBasic and have not found it in use. I apologize if this has been asked before, but I do not have easy access to the Internet and cannot search the archives. Thank you, Sara __________________________________________________________ This message is from Mott MacDonald Ltd. 48/52 Capital House, Andover Road, Winchester SO23 7BH, England Telephone Direct: 01962 893225 and Fax: 01962 863224 Email: [EMAIL PROTECTED] Website: http://www.mottmac.com Registered in England number 1243967 Registered office St Anne House, 20- 26 Wellesley Road Croydon, CR9 2UL, England __________________________________________________________ --------------------------------------------------------------------- List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]