473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

list box multivalues retrieval

553 512MB
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 1701
Killer42
8,435 Expert 8TB
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.Selected(n). Have a look through the properties anyway, you shouldn't have any trouble finding it.
Jul 17 '07 #2
questionit
553 512MB
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.Selected(n). Have a look through the properties anyway, you shouldn't have any trouble finding it.
Jul 17 '07 #3
Killer42
8,435 Expert 8TB
Not sure whether it's the problem, but try changing line 4 to "For n = 0 To List21.ListCount - 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 Expert 8TB
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 512MB
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 512MB
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 Expert 8TB
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 512MB
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.ListCount - 1
If Me.List21.Selected(n) = -1 Then
nA(c) = List21.Value
'MsgBox (Me.List21.Value)
'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 Expert 8TB
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
questionit
553 512MB
.Value will represent the value of the current selection. Basically, i want to store the selected values in an array

but this .Value part of my code is being highlightted because of any error, couldn't figure out why

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 #11
Killer42
8,435 Expert 8TB
Well it's obviously a lot different to the listbox control that I'm familiar with.

Does it have another property that might return the items in the list, such as .Item or .List?
Jul 19 '07 #12

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

Similar topics

9
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 =...
4
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...
1
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...
0
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...
10
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
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
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...
10
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...
7
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...

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.