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
11 1701
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.
I am keep on getting error : "Invalid use of Null" - only if i select any value afer the first one in List Box - Dim nA() As String
-
Dim c As Integer
-
c = 1
-
For n = 1 To List21.ListCount
-
If List21.Selected(n) Then
-
nA(c) = List21.Value
-
MsgBox (nA(c))
-
c = c + 1
-
Else
-
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.
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.
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.
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.
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?
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.
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.
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?
.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?
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?
Sign in to post your reply or Sign up for a free account.
Similar topics
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 =...
|
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...
|
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...
|
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...
|
by: Jeff Williams |
last post by:
How can I get a list of the Groups both Local and Domain groups a User
belongs to.
|
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
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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
|
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...
|
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...
|
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,...
|
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...
| |