|
-
Sep 8th, 2007, 02:03 AM
#1
Thread Starter
Addicted Member
Listbox??!!
ye, i was just wondering what is the maximum ammount of items a LitsBox can hold??
-
Sep 8th, 2007, 02:11 AM
#2
Banned
Re: Listbox??!!
I dont think there is one, it may freeze after so many, but it should load after some time.
-
Sep 8th, 2007, 02:45 AM
#3
-
Sep 10th, 2007, 01:39 PM
#4
Frenzied Member
Re: Listbox??!!
Unlimited. But listcount and listindex support only 32K, it starts going minus after that. But you can use the API directly.
-
Sep 10th, 2007, 01:52 PM
#5
Re: Listbox??!!
A listbox's size is rather huge. I just wrote code to randomly generate 100,000 capped strings of 9 characters apiece. I jump-sorted these in ascending order from AAABXYXQS to ZZZWQMJGD. In 19 seconds the results appeared in the listbox.
-
Sep 10th, 2007, 01:59 PM
#6
Frenzied Member
Re: Listbox??!!
Also each row is limited to 1024.
But if you use api its unlimited.
-
Sep 10th, 2007, 02:20 PM
#7
Re: Listbox??!!
You'll use API to extend the capacity of listbox. But do you want to get into that much trouble? Dang! Just use listview.
-
Sep 10th, 2007, 02:54 PM
#8
Re: Listbox??!!
 Originally Posted by Code Doc
A listbox's size is rather huge...
It is not - as Hack mentioned it's limited to 32K (but to be exact it's an Integer's boundary of 32767).
You can load huge amount of list items however you won't be able to access any of it beyond the 32767 index using conventional methods:
Code:
Option Explicit
Private Sub Form_Load()
Dim i As Long
For i = 0 To 32768 'you have a million here...
List1.AddItem i
Next i
End Sub
Private Sub Command1_Click()
MsgBox List1.List(32768) '<<< you should get an overflow error
End Sub
So, as Zynder said use Listview control instead.
-
Sep 11th, 2007, 10:24 AM
#9
Re: Listbox??!!
Rhino, the OP asked "i was just wondering what is the maximum ammount of items a LitsBox can hold??"
--------------------
He said nothing about accessing any of the information in the list box. Right? I merely showed that 100,000 strings of 9-bytes apiece would fit inside the list box without getting an error. And, you can scroll to any of them on the screen.
-
Sep 11th, 2007, 10:29 AM
#10
Re: Listbox??!!
 Originally Posted by Code Doc
He said nothing about accessing any of the information in the list box. Right? I merely showed that 100,000 strings of 9-bytes apiece would fit inside the list box without getting an error. And, you can scroll to any of them on the screen.
I know but is there point to do that? Common sense, right?
-
Sep 11th, 2007, 11:03 AM
#11
Re: Listbox??!!
I'll give you a point for that.
-
Sep 11th, 2007, 12:30 PM
#12
Re: Listbox??!!
Rhino said, "I know but is there point to do that? Common sense, right?"
------------------------------
If the elements added to the listbox are an array, you have accress to that array. The list box may then be used for viewing only. In my case, all of the elements were in a sorted array, so accessing the listbox for information that it contained meant nothing because the array was defined in memory.
-
Sep 11th, 2007, 01:12 PM
#13
Re: Listbox??!!
 Originally Posted by Code Doc
If the elements added to the listbox are an array, you have accress to that array. The list box may then be used for viewing only. In my case, all of the elements were in a sorted array, so accessing the listbox for information that it contained meant nothing because the array was defined in memory.
I hope you are not serious but you sound like you are...
Why do you need to keep in memory two identical arrays? Are you kidding me?
-
Sep 11th, 2007, 03:37 PM
#14
Re: Listbox??!!
Rhino asked, "Why do you need to keep in memory two identical arrays? Are you kidding me?"
--------------------------
This may be hard for you to believe. My jump sort routine will sort huge arrays faster than a listbox (with the Sorted property turned on) can read unsorted entries into the listbox. I measured this improvement when Ellis Dee was building the Sorting Routines Codebank in May and June of this year.
So, when working with a huge array, I often jump sort the array first and then add the sorted array elements to a listbox with the Sorted property turned off. Sounds goofy, but it works. 
Now you and Hack have pointed out another potential listbox weakness. When the ListCount exceeds 32,768, the information retrieval from the list is lost beyond that number. So, the sorted listbox somewhat dies at that point, whereas my sorted array hangs onto all the information to the upper bound.
-
Sep 11th, 2007, 03:43 PM
#15
Re: Listbox??!!
And what are you going to do with your array if you cannot access listindex greater than integer using conventional approach?
I'm trying to get you answer this question but somehow you manage to ignore that...
-
Sep 11th, 2007, 04:03 PM
#16
Re: Listbox??!!
Rhino asked "And what are you going to do with your array if you cannot access listindex greater than integer using conventional approach?"
-------------------------------------
Hmmm. Not sure exactly what you mean. I just built a 100,000-item listbox containing 9-character string entries. I clicked on the list at item 100,000. Although the List1.ListIndex value was invalid, List1.Text was exact in the message box.
Code:
Private Sub List1_Click()
MsgBox "Item " & Str$(List1.ListIndex + 1) & " is " & List1.Text
End Sub
So, as long as you don't mind not knowing what the List1.Index value is, the information in the listbox is still there for the taking.
-
Sep 11th, 2007, 07:54 PM
#17
Frenzied Member
Re: Listbox??!!
and you can always get the list index with a simple one line sendmessage API.
-
Sep 11th, 2007, 08:12 PM
#18
Re: Listbox??!!
I did emphasize few times already on "conventional" or intrinsic method.
Since SendMessage is not intrinsic maybe you want to show how it could be utilized.
I'm sure many would appreciate that.
-
Sep 11th, 2007, 10:37 PM
#19
Frenzied Member
Re: Listbox??!!
Instead of
List_Add(0).AddItem SqlString
You can use
Call SendMessage(List_Add(0).hwnd, &H180, 0, ByVal CStr(SqlString))
This will add to the listbox a item even if the lentgh of the string is greater than 1024.
Now to read anything use
Dim sItemText As String * 32000
Call SendMessage(List_Add(0).hwnd, &H189, 50000, ByVal sItemText)
This will give you in sItemText the text of the requested index.
Dont Forget to put the following in your declarations.
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|