473,749 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

list box multivalues retrieval

553 Contributor
I have a List Box with multi-select option = "Extended".

how can i retrieve all the selected values into a variable/array variable

i have tried but cant do like List4.Value(1) ..


help please

Thanks
Jul 16 '07 #1
11 1717
Killer42
8,435 Recognized Expert Expert
I have a List Box with multi-select option = "Extended".
how can i retrieve all the selected values into a variable/array variable
i have tried but cant do like List4.Value(1) ..
I believe one of the properties returns an array of booleans corresponding to the list. Um... I think the property is called .Selected. If so, you would use an array or something to check ListBox.Selecte d(n). Have a look through the properties anyway, you shouldn't have any trouble finding it.
Jul 17 '07 #2
questionit
553 Contributor
I am keep on getting error : "Invalid use of Null" - only if i select any value afer the first one in List Box

Expand|Select|Wrap|Line Numbers
  1. Dim nA() As String
  2. Dim c As Integer
  3. c = 1
  4.  For n = 1 To List21.ListCount
  5.    If List21.Selected(n) Then
  6.      nA(c) = List21.Value
  7.       MsgBox (nA(c))
  8.          c = c + 1
  9.    Else
  10.    End If
Any idea whats wrong.
Thanks

I believe one of the properties returns an array of booleans corresponding to the list. Um... I think the property is called .Selected. If so, you would use an array or something to check ListBox.Selecte d(n). Have a look through the properties anyway, you shouldn't have any trouble finding it.
Jul 17 '07 #3
Killer42
8,435 Recognized Expert Expert
Not sure whether it's the problem, but try changing line 4 to "For n = 0 To List21.ListCoun t - 1". VB has this rather annoying tendency to begin all its arrays at zero, which means they actually end one place earlier than you expect.

In other words, if there are 10 items in the list, they are actually numbered from 0 to 9, not 1 to 10 as any reasonable person would expect. But the ListCount will be 10, because it's simply the number of entries.
Jul 17 '07 #4
Killer42
8,435 Recognized Expert Expert
One more thing. You didn't say which line produced the error. But just form what you posted, I don't think the array nA() has any occurrences. You haven't defined anywhere what size it is. Not sure whether that's a problem (may depend on your option settings) but it doesn't look right to me.
Jul 17 '07 #5
questionit
553 Contributor
I am gettin error on this line:

nA(c) = List21.Value

This works fine with my VB
Dim nA() As String

but i also have tried with this:
Dim nA(10) As String

but still the same error comes "Invalid use of Nll Error 94" The strange thing is if i select first value in list box, i never get any error but only with other values?



One more thing. You didn't say which line produced the error. But just form what you posted, I don't think the array nA() has any occurrences. You haven't defined anywhere what size it is. Not sure whether that's a problem (may depend on your option settings) but it doesn't look right to me.
Jul 17 '07 #6
questionit
553 Contributor
one more strange thing:

Dim p As String

p = List21.Value -- error line

MsgBox p

now only on this code, i get error 94 "invalud use of Null" i cant figure out why


I am gettin error on this line:

nA(c) = List21.Value

This works fine with my VB
Dim nA() As String

but i also have tried with this:
Dim nA(10) As String

but still the same error comes "Invalid use of Nll Error 94" The strange thing is if i select first value in list box, i never get any error but only with other values?
Jul 17 '07 #7
Killer42
8,435 Recognized Expert Expert
I think the whole problem may revolve around your use of the .Value property. In my experience (up to VB6) the listbox control doesn't have a Value property. The values in the list have always been accessed through the .List() array property.
Jul 17 '07 #8
questionit
553 Contributor
List does have .Value propertyas i am using VBA.

But this is my code , which keeps on giving error and the statement in Else Clause is being executed all the time even though i select items in the List:

For n = 0 To List21.ListCoun t - 1
If Me.List21.Selec ted(n) = -1 Then
nA(c) = List21.Value
'MsgBox (Me.List21.Valu e)
'c = c + 1
Else: MsgBox "nothing selected"
End If
Next n

any other clue?

I think the whole problem may revolve around your use of the .Value property. In my experience (up to VB6) the listbox control doesn't have a Value property. The values in the list have always been accessed through the .List() array property.
Jul 18 '07 #9
Killer42
8,435 Recognized Expert Expert
I don't get it. If this is a list, in which multiple items can be selected, then what exactly does the .Value property represent?
Jul 19 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

9
1949
by: Rogue9 | last post by:
Hi, I´m trying to retrieve an item from a list using a reference called ´draw´' (which is an integer from 1 to 792 in a while loop) using:- draw = 1 while 1: if draw == 792: break b1 = someOtherList r1 = b1
4
4343
by: JC | last post by:
Hello, I'm running into a huge wall with linked lists. If anyone outhere can help me, I'll appreciate it very much. Here is my delima! I need to create a simple list of numbers. which I can do, by assigning the pointer to *next.
1
1652
by: Lyle H. Gray | last post by:
We load a table from a text file using Data Transformation Services. The source file is already sorted by primary key order. After the DTS load, the default retrieval order on the target table (select * from targettable) appears to be random. I know that theoretically the retrieval order from a SELECT statement isn't guaranteed, but this is the first time that I've actually had a default retrieval not follow the primary key order in...
0
7541
by: Brian Henry | last post by:
Since no one else knew how to do this I sat here all morning experimenting with this and this is what I came up with... Its an example of how to get a list of items back from a virtual mode list view in .NET 2.0 with multiple selection turned on... since the .NET documentation is EXTREAML vague on how to do this and offers no clue on what the virtual mode events do or how to use them... just thought this might help someone else out...
10
26807
by: Jeff Williams | last post by:
How can I get a list of the Groups both Local and Domain groups a User belongs to.
10
1657
by: Sebastian Bassi | last post by:
I have a two column list like: 2,131 6,335 7,6 8,9 10,131 131,99 5,10
12
3945
by: grace | last post by:
i am wondering why my database retrieval becomes too slow...we set up a new server (ubuntu, breezy badger) machine where we transferred all our files from the old server.. Our new server uses Asus p5pe-vm motherboard and an Intel Pentium D 3.0Ghz processor, compared to the old one where we uses asrock motherboard and AMD Duron. Both has the same version of mysql installed... To summarized, both machine has the same configuration except...
10
10503
by: Aditya | last post by:
Hi All, I would like to know how it is possible to insert a node in a linked list without using a temp_pointer. If the element is the first element then there is no problem but if it is in between then what is the best solution.
7
1713
by: Clamato | last post by:
Hello everyone, I've been working on this for a bit and wonder if anyone can shed some light on my situation. My ultimate goal is to have a user select an item in a list box, have one column in the list box display in either a text box or preferrably a button based on what is selected. The form is being used currently as a rudimentary document retrieval system. The document that is saved on a shared drive is linked in a table by a...
0
8833
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9568
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9389
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8257
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6801
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6079
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3320
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2794
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.