Re: VB6 LISTBOX problem

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"mayayana" <mayaXXyana1a@xxxxxxxxxxxxxxxx> wrote in message
news:ewfd$AyEIHA.3980@xxxxxxxxxxxxxxxxxxxxxxx
I have a problem with a listbox.
I believe the problem is the 'limitation' of the 'listbox' control
rather than anything I've done.

I want to add 47,232 entries to the listbox,
I've added the records using 'LIST1.ADDITEM x' without any problems (I
think, data looks ok).

If you look at the ListCount property you'll
see it's an integer. So that's your limitation.
No need to run Ivar's code. All he was trying
to say is that it doesn't work. (I wasted my time
trying it so others won't have to. :)

I've seen code, I think it was in VBPJ a few years
ago, that designs a fast Listbox by loading it
dynamically. You might check around for that. I
think the way it worked was to store the values
in an array and then subclass the Listbox, updating
it's display as it's scrolled, so that it's never actually
holding more than a few items.



Just to elaborate, Integers in VB6 are 16-bit numbers that range from -2^15
to 2^15 -1, or -32,768 to 32,767.

My guess is that the ListCount property properly increments up to 32,767,
then the next value after that is -32,768, then -32,767, and so on up
to -18,304. So the value -18,304 corresponds to 32,768 + (-18,304 + 32,768)
= 47,232. Of course you can't take advantage of this (you don't know how
many times the property cycled through valid values), but it explains where
the number came from. In any case that many entries in a listbox is not
practical.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--


.



Relevant Pages

  • Re: List Box ListCount property seems to be incorrect...
    ... Then asking for the ListCount returns zero. ... I occasionally need to requery this ListBox ... > and I do this by comparing its ListCount property to zero. ... > Bob ...
    (microsoft.public.access.forms)
  • Re: List Box ListCount property seems to be incorrect...
    ... > Bob, I am unable to reproduce this in Access 2000 or 2003, using either a ... > Category table as RowSource. ... I occasionally need to requery this ListBox ... >> and I do this by comparing its ListCount property to zero. ...
    (microsoft.public.access.forms)
  • Re: List Box ListCount property seems to be incorrect...
    ... > Still in the Immediate window, I change the RowSource so no records match: ... I occasionally need to requery this ListBox ... >> and I do this by comparing its ListCount property to zero. ...
    (microsoft.public.access.forms)
  • Re: VB6 LISTBOX problem
    ... Why not use some sort of Sort? ... I believe the problem is the 'limitation' of the 'listbox' control ... I know adding so many entries to a listbox isn't ideal, ...
    (microsoft.public.vb.general.discussion)
  • Re: VB6 LISTBOX problem
    ... I believe the problem is the 'limitation' of the 'listbox' control ... I know adding so many entries to a listbox isn't ideal, ...
    (microsoft.public.vb.general.discussion)