ListBox MultiSelection Problem

Hello,

I am building a form which will play with all selected lines in
ListBox. I have ListBox filled like that:

Option1
Option2
Option3

and I select by mouse Option1 and Option2. The problem is as follows:
How to get these selected elements (I mean strings like 'Option1',
'Option3', not indexes).

My code:

For i = 0 To MyList.ListCount - 1
        If MyList.Selected(i) Then
                MyString = MyString & MyList.??? // what to put
here??? cause ItemData return index, not string value
        End If
    Next

Regards, Jan

0
janKowalskiPL
8/19/2007 7:43:54 PM
access.formscoding 7493 articles. 0 followers. Follow

2 Replies
835 Views

Similar Articles

[PageSpeed] 33

MyString = MyString & MyList.column(N,i)
where N is the zero-based count from left to right.
(1st column is 0, 3rd column is 2)


janKowalskiPL@gmail.com wrote in
news:1187552634.209329.213580@d55g2000hsg.googlegroups.com: 

> Hello,
> 
> I am building a form which will play with all selected lines
> in ListBox. I have ListBox filled like that:
> 
> Option1
> Option2
> Option3
> 
> and I select by mouse Option1 and Option2. The problem is as
> follows: How to get these selected elements (I mean strings
> like 'Option1', 'Option3', not indexes).
> 
> My code:
> 
> For i = 0 To MyList.ListCount - 1
>         If MyList.Selected(i) Then
>                 MyString = MyString & MyList.??? // what to
>                 put 
> here??? cause ItemData return index, not string value
>         End If
>     Next
> 
> Regards, Jan
> 
> 



-- 
Bob Quintal

PA is y I've altered my email address.

-- 
Posted via a free Usenet account from http://www.teranews.com

0
Bob
8/19/2007 9:52:15 PM
Jan,

You could shorten the run time of the code a little if instead of looping 
through each item in the list, you only loop through the ItemsSelected 
collection.  

Dim MyString as variant
Dim varItem as variant
For each varItem in MyList.ItemsSelected
    MyString = (MyString + ",") & chr$(34) & MyList.column(N, varItem) & 
chr$(34)
Next

I've made MyString a variant so that I can concatenate the comma as a list 
separater using the plus sign rather than the ampersand.  This technique 
results in 
dropping the comma the first time through the loop, since MyString will be 
NULL during the first pass.  

See Bob's post regarding the Column reference to N.

HTH
Dale
-- 
Email address is not valid.
Please reply to newsgroup only.


"janKowalskiPL@gmail.com" wrote:

> Hello,
> 
> I am building a form which will play with all selected lines in
> ListBox. I have ListBox filled like that:
> 
> Option1
> Option2
> Option3
> 
> and I select by mouse Option1 and Option2. The problem is as follows:
> How to get these selected elements (I mean strings like 'Option1',
> 'Option3', not indexes).
> 
> My code:
> 
> For i = 0 To MyList.ListCount - 1
>         If MyList.Selected(i) Then
>                 MyString = MyString & MyList.??? // what to put
> here??? cause ItemData return index, not string value
>         End If
>     Next
> 
> Regards, Jan
> 
> 
0
Utf
8/20/2007 1:34:00 PM
Reply:

Similar Artilces:

Problems with XmlNodeList
Hi, I'm trying to get an instance off a XmlNodeList without using selectNodes(...) XmlNodeList test1 = new XmlNodeList(); (C#) but that doesn't work. What's my mistake? greetings Ernst Juergen bigeddie wrote: > I'm trying to get an instance off a XmlNodeList without using > selectNodes(...) > > XmlNodeList test1 = new XmlNodeList(); (C#) > > but that doesn't work. XmlNodeList in System.Xml is an abstract class, you can't construct instances of abstract classes. When you use e.g. ChildNodes or SelectNodes in the .NET framework then yo...

problem with GetTextMetrics()
isn't TEXTMETRIC.tmMaxCharWidth supposed to be the width of the widest character in the font in pixels? with the DEFAULT_GUI_FONT on XP, shouldn't that be 'W'? 'W' is 9 pixels wide, but tmMaxCharWidth is 22. I'm sure the correct font is selected into the DC which I am running GetTextMetrics() on. SDK: The TEXTMETRIC structure contains basic information about a physical font. All sizes are specified in logical units; that is, they depend on the current mapping mode of the display context. Which means use LPtoDP to convert the units. AliR. "stork" ...

Inbox display problem
My 4 year old got on my computer and now my email is only showing the received column. I would like to have the From and Subject put back in there. Don't know and can't figure out how he did it. Anyone? Frank Frank <anonymous@discussions.microsoft.com> wrote: > My 4 year old got on my computer and now my email is only > showing the received column. I would like to have the > From and Subject put back in there. Don't know and can't > figure out how he did it. Anyone? In addition to what Milly said, you can also reset the current view to its defaul...

Printing scale problem beetween Project 2003 and Project 2007
Hi, I have a little problem on 2 different computers with the same file. On one of the computers I have Project 2003 SP3 and on the other one I have Project 2007. The file needs to be printed on 1 page only and was saved like that. When I open the same file on each computer (without changing any options) I don't have the same result, the Print Preview with 2003 is ok. Print Preview with Project 2007 seems to have been reduced to fit the page hence it looks half the size of the preview lengthwise in 2003. Do you have any idea of what could be the problem? Thanks ...

Another Hibernation problem
Tom and al! - sorry to bother you again. My system is now quite stable but occasionally I get another unexpected shutdown soon after returning from hibernation: and this shows up in the event viewer as the event preceding the shutdown. Previously I had a video driver problem that conflicted with something. Would you now say I now have a DHCP server conflict? Regards Mervyn (follows event viewer paste) Event Type: Warning Event Source: Dhcp Event Category: None Event ID: 1003 Date: 29/01/2010 Time: 08:41:06 User: N/A...

E2K3
We currently have a mixed mode environment with Exchange 5.5 on NT 4.0 and Exchange 2003 on Windows 2000. We have completed the migration of our mailboxes and public folders to E2K3 and are in the process of decommissioning our 5.5 Site. We have a policy setup on our mail stores to send a warning when a user reaches 95MB and to prohibit sending at 100MB. We also have standards in place regarding the storage group/mail store location of our users on the E2K3 servers. The first problem we are experiencing is ESM is reporting a mailbox size that is significantly larger than what Outlook 2002 ...

Problem with Outlook automatically deleting messages
After reading received messages in Outlook, Outlook deletes the message upon closure of the message. The message just disappears. Doesn't go to the deleted folder, just disappears. Any help on figuring out the problem, and how to correct it?? Thanks for your help with this bizarre problem. Not bizarre at all. You have set a filter on your Inbox view, such as "Unread messages" or "Sort by icon." Remove it. -- Russ Valentine [MVP-Outlook] "Lois M" <anonymous@discussions.microsoft.com> wrote in message news:2e30701c46c74$85150550$a601280a@phx...

Outlook 2003 offline folders sync problem..
I keep getting this error in my Outlook 2003, every 5 minutes :-( 10:44:56 Synchronizer Version 11.0.6352 10:44:56 Synchronizing Mailbox 'Cristian Croitoru' 10:44:56 Synchronizing Hierarchy (in red) 10:44:56 Error synchronizing folder (in red) 10:44:56 [8004010F-501-8004010F-0] (in red) 10:44:56 The client operation failed. (in red) 10:44:56 Microsoft Exchange Server Information Store (in red) 10:44:56 For more information on this failure, click the URL below: (in red) 10:44:56 http://www.microsoft.com/support/prodredirect/outlook2000_us.asp?err=8004010f-501-8004010f-0 10:44:56 Done ...

Problem print an email
My brother can not print our emails. he is using Microsoft Outlook Express 6.00.2900.2180 and i am using Outlook 2000, SP-3. I am the only person he gets email from that will not print. my format is Plain Text, and it is just words--no pix, nothing special. i assume there is something on my end which keeps him from printing. can someone help me out?? thanks, ron Please insert an E between the n & t, to reply via email. rondi <rdiehl@sandpoint.nt> wrote: > My brother can not print our emails. he is using Microsoft Outlook > Express 6.00.2900.2180 and i am using Outl...

Install problem, can't locate SQL instance same machine
I'm trying to install Action Pack's CRM software on my server in-office. I can't even get the silly thing to find SQL and its the same machine!! What gives!?! The server is Win 2000 AS /SP3 and is a DC, but not any of the FSMO role owners. It also has exchange running it. I go about 3 screens into the install where it asks to select my SQL and create new or use existing databases. I try typing in the UNC for my server and say next, it sits the for about 15 seconds and says failed to authenticate/rights issue. I'm logged in as domain admin, and SQL security is set at Windo...

Problem displaying data in a Editbox
Hello. I am trying to display serial data in Edit box. The serial handler code is obtained from http://www.codeproject.com/KB/system/serial.aspx. In the serial handler, I use the SetwindowText to display the string but instead I get an occasional first character being displayed in the edit box instead of the full string. I have set the edit box properties with multiline, auto vertical scroll, want return, read only. I have also debug the code and place the string in the watch window and it seem to receive the full character on-screen. Any help please. Thanks Paul <eziggurat@gmail.com...

Modeless Dialog from MFC Regular DLL opened from EXE problems
Hi, Resources for the MFC modeless dialog are in a Regular DLL with MFC statically linked, No message overrides are set with the dialog, it is a generic dialog with only the OK and Cancel buttons. I choose a MFC AppWizard(exe) Dialog based for the calling EXE and used Run-Time Dynamic Linking to the DLL. Tried a couple I different approaches base on what I found on the newsgroup and the usual help sites. I know that I need to keep the modeless dialog from going out of scope after it is created so this is what I tried two different methods so far but I still can't get the dialog to hang ar...

IE/OE startup problem
On a system using Win 98SE IE6 and OE when trying to open IE or OE I get a screen that wants to guide me to connect to the net via MSN asking for dialup info. I am using a cable connection and the system was fine until I had reason to reboot it. Try posting this in an Outlook Express news group - this is not one of them. Outlook is a part of Microsoft Office and is what this group supports. Outlook Express is a part of Internet Explorer and has its own news groups. You can also find some good Outlook Express information here: http://insideoe.tomsterdam.com --� Milly Staples [MVP - ...

OWA access problem
Hello I have exchange 2000 with SP3 on Windows 2000 with SP4, we have configure OWA to access mail from the outside of the company. Some computer can access mailbox without any problem and they have to put only one time user and pass,but some computer cannot because browser Continuously asking user, pass and domain name evnet we select the remember password. And at the end it say access is denied. There is another difference on some client accessing OWA from outside will get user name and password longin screen other may get the users, pass and domain why this difference? Nagori ...

Problem when trying to export messages
I have a fresh (8/1/03) install of OE6 and XP Pro all completely up to date via Microsoft's updater website. The problem I'm having is that when I try to export my messages for backup purposes I get the following error message: "The export could not be performed. An error occurred while initializing MAPI." I've looked in the Knowledge base, but to no avail. Can anyone enlighten me and help me solve this problem? Darla ...

Excel 2003 Autocorrect Options problem
Hi-- I just got a new computer at work with Excel 2003 on it. Whenever I try to choose "Tools/AutoCorrect Options" the Basic File Seach Task Pane opens up instead of the AutoCorrect Options Box. I was curious if anyone else was seeing this behavior. I can get into the AutoCorrect Options Dialog box through Word, but not through Excel. I'm willing to try re-installing XL2003, but don't want to hassle with it, if others are having the same problem. Thanks! Laura :-) No problems here, try to repair it under help>detect and repair (keep the cd handy if asked for) --...

problem posting questions
test any problems posting to this list today? i have tried twice and it is not working. thanks. Mike Better use a Newsreader like OE. Read this from Dave Peterson '*************************************************** You may want to connect to the MS newsgroups directly. Chip Pearson has some notes written by Leonard Meads at: http://www.cpearson.com/excel/DirectConnect.htm David McRitchie's notes at: http://www.mvps.org/dmcritchie/excel/xlnews.htm http://www.mvps.org/dmcritchie/excel/oe6.htm Tushar Mehta's notes at: http://www.tushar-mehta.com/misc_tutorials/oe_ng/index.ht...

Problem Sending e-mails #2
People to whom I've sent e-mails recently haven't had them. When I check the settings & use the test account setting button I get a message stating"......unable to send test message. Please verify E-mail address field" I have checked the fields and they are all in order. Wondering if this could be a sever problem I sent a test message using Thunderbird & it was received ok. Any suggestions please? Henry ...

Activex, CSocket and CResourceException Problem
Hi, I'm trying to write activex control with mfc which connect to the another app through socket. The socket conn form activex to the app is made on a different thread. The thread is initialize by function: HANDLE threadHandle = CreateThread(NULL,NULL, (LPTHREAD_START_ROUTINE)ThreadProc, (LPVOID)this, NULL, &dwID); and everything works correct except this that i,m tryin to connect from another instance of this activex i get CResourceexception. Anu ideas how to avoid this? CSocket is declare localy and in ThreadProc is no loops...

MS Access & Citrix
Hi, all. We have a home-grown Access application that approximately 50 users use to access different, but related, databases on different Linux servers across the US. We are trying to combine all these different databases into one database that everyone can access through a Citrix server. In the initial (very) testing phase, we have found some strange problems with our Access app that may be related to the programming within the application or may be related to the Citrix side of things (although when we try to do an analagous task going just through Access itself we don't have the same...

Growing Exchange store problem
Hi, I have an Exchange 2003 Standard server that was happily running for 18 months. We purchased and installed reporting application to monitor usage. It runs as a service and uses ExOleDB to pull data from the Exchange store. The developer has indicated that it is 'read only' to the database. However, every time it runs we see instant and significant growth in the DB. We actually upgraded to Enterprise before we discovered this problem (5000 dollars wasted!). The database is now sitting at 22gig but ESM mailbox sizes only add up to 3.5 gig. Previous offline defrags have not ...

problems with eps file type
Hello I am attempting to create my business card in Publisher. My logo's are eps files. Publsiher would not show the logo image (I guess the logo image did not have a tiff preview file embedded). I would like to upload my finished business card as an eps file type. The online printers do not accept ps file type. Can I simply change the ps extension to eps? If Publisher does not work well with eps file types (which appear to be an industry standard) then what other program should I consider using? I am baffled at how difficult this effort has been - My guess is that eps is perhaps...

Send/Receive Problem #12
I have my Microsoft Outlook 2003 set up for manual send/receive. Every once in a while, when I hit F9 or send/receive, nothing happens. If I close out of the program for several minutes and re-open it, it will work. Any ideas? The mapi spooler is locking up, often because you are doing too-frequent send and receives. -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com Outlook Tips by email: dailytips-subscribe-request@lists.outlooktips.net EMO - a weekly newsletter about Outlook and Exchange: E...

Macro problem #4
Good Morning: A vendor sent a workbook with several spreadsheet. Each spreadsheet has hundreds of rows. I would like to change the all upper case he used to proper. I used the =proper function and it works well. Here is my problem. I tried to build a macro that whatever column I cliced on a new column would be inserted, the =proper function would run all the way down the column and then copy and paste the values over the column that has the upper case. Since it worked without the macro, I was surprised when the macro didn't work. I use Excel 2002 with XP. Thank you for any help. ...

Contract Administration problem
Hi I am setting up Contract Admin for the first time. However, having done all setups and on entering a new contract via Transactions>Contract Admin>Contract Entry Update and selecting "New" I get the following mesage :- "A valid document number could not be found" I cannot find anything on knowledgebase. Any ideas or suggestions would be gratefully received. Rod Found the following: Please make a backup before deleting any records. This my be caused by a bad record in the SVC00608 (Contract Site Header) table. Execute the following script in SQL against t...