I found that the max item for list box in VB is around 32k items (index will be negative if more than that amount). Is there any ways to add more than 32k items in List Box ? maybe use similar control ? Thank you before
When you have more than 32K items in a list box, that means the way you are approaching the solution is wrong. Do you expect a User to go through 32K items to select what he/she wants. May be you need to re-look at how you are doing things.
The problem is, i cannot change how the application works since it is not designed by me. This list box is for listing down all the product that we have. Actually, there are some workaround for this :
1. categorized the product, and then add 1 combo box for the category. the product populated will only be the product that user choose.
2. Use 1 temporary variable to contain all the Product Code and Display only 32k first item, and add "Continue..." as the last item to go to the rest of the item.
However, i just feel that there must be a way to populate all the ProductCode without using this workaround.
Yes, the limit is exactly 32767, which is max. positive integer value.
You might replace the ListBox with an apropriately configured ListView. I think, a Listview's index is a Long, so you wouldn't come to a limit so fast.
You have to add 'Microsoft Windows Common Controls 6.0' to your toolbox and get a ListView control on your form.
Note that the ListView has different structure and therefore different syntax to the ListBox, but it's more versatile.
Scroll Bar in VB have limit of 32767 items. But this isn't a problem for making a list box as a user control to manage say 500000 items using a VScrollBar.
I wrote a user control named Fat List Box, and in the attachment below is an example of using it.
this is a part of coding on a Vscroll inside user control:
LINES are lines we see on listbox
Logicallines times Vscroll1.max are items on the list (but maybe some more less than logicallines, so for last page we do trick..as you read:
topitem is the hidden item before the item at first visible line
Private Sub VScroll1_Change()
If Not State Then
If logicallines > LINES Then
If VScroll1 = VScroll1.Max Then
topitem = itemcount - LINES - 1
Else
topitem = (VScroll1 * logicallines) \ 2
End If
Else
topitem = (VScroll1 * LINES) \ 2
End If
IsCur = False
Timer1.Enabled = True
End If
End Sub
The question is 3 years old and was answered, no point in rasing a post from the dead not to mention a list box that holds more than 32 k items is pretty well useless as no one in thier right mind would put a list box on a form with that many items in it.
In our days computers are very fast. Even the population of my listbox with 500000 items is very fast. I have an application named fotodigitallab which introduce the FotoList a big list of images as names in this listbox (earlier version, with one colour for all items), which maps a tree of folders from a mass media (hard disk or memory card). If anyone have an 8 gigabyte memory card it is possible to have >32k jpgs files. From scroll bar you can go to any "page" (as dglienna says). It is a search with one control. So before three years...8 gigabytes card was rare, but know we can face problems who needs a control with more than 32k items.
I think a listbox first for the user interaction, no to substitute an array or even better an advanced data object. It is possible to make a guicksort on the items, from an offset A to an offset B (in the example I haven't include the sort routine). In my mind the listbox has a temporary use. You have all you need in the memory, so you don't save data for later use as with a database.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.