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 1713
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.
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.Selecte d(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.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.
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.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.
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?
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 = someOtherList
r1 = 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 can do, by assigning the pointer to *next.
|
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...
|
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...
|
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 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...
|
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.
|
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...
|
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,...
|
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...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |