|
| Author |
Message |
Lorin
Joined: 04 Oct 2007 Posts: 312
|
Posted: Wed Feb 27, 2008 9:49 pm Post subject: ListBox Negative Count |
|
|
VB6SP6
I added items to a ListBox and got
lstFolders.ListCount returning -32768
I guess I will not use a Listbox.
But why the negative number?
Why does it not throw an error?
What can I use?
A control required little maintenance.
lstFolder.additem
An array needs maintenance.
instantiate
ReDim Preserve
etc.
I need a fast something.
Something that will handle up to 100K at least.
Does not need to be visible.
Where can I find the size restrictions for the contrls in VB6SP6?
Archived from group: microsoft>public>vb>general>discussion |
|
| Back to top |
|
 |
Lorin
Joined: 04 Oct 2007 Posts: 312
|
Posted: Wed Feb 27, 2008 9:52 pm Post subject: RE: ListBox Negative Count |
|
|
And I guess I should add that I want to add only unique items.
The LsitBox was fast and I used the API call to check for existing entry.
So the replacement needs to be similar.
"Lorin" wrote:
> VB6SP6
>
> I added items to a ListBox and got
>
> lstFolders.ListCount returning -32768
>
> I guess I will not use a Listbox.
> But why the negative number?
>
> Why does it not throw an error?
> What can I use?
> A control required little maintenance.
> lstFolder.additem
> An array needs maintenance.
> instantiate
> ReDim Preserve
> etc.
> I need a fast something.
> Something that will handle up to 100K at least.
> Does not need to be visible.
> Where can I find the size restrictions for the contrls in VB6SP6?
> |
|
| Back to top |
|
 |
Karl E. Peterson
Joined: 04 Oct 2007 Posts: 4836
|
Posted: Wed Feb 27, 2008 9:59 pm Post subject: Re: ListBox Negative Count |
|
|
Lorin wrote:
> And I guess I should add that I want to add only unique items.
> The LsitBox was fast and I used the API call to check for existing entry.
> So the replacement needs to be similar.
Hmmmmm, so you know how to use the API with a listbox? Why, then, are you using VB
to get an itemcount? (Try LB_GETCOUNT instead.)
--
..NET: It's About Trust!
http://vfred.mvps.org |
|
| Back to top |
|
 |
Karl E. Peterson
Joined: 04 Oct 2007 Posts: 4836
|
Posted: Wed Feb 27, 2008 9:58 pm Post subject: Re: ListBox Negative Count |
|
|
Lorin wrote:
> VB6SP6
>
> I added items to a ListBox and got
>
> lstFolders.ListCount returning -32768
Oops, one too many. (Tho some might say, that's a bit of an understatement!)
> I guess I will not use a Listbox.
Your call.
> But why the negative number?
Because Integers, what VB uses for the ListIndex property, are signed.
Try this:
Debug.Print &h7FFF, &h8000, &h8001
Then this:
Debug.Print &h7FFF&, &h8000&, &h8001&
> Why does it not throw an error?
Because it's not.
> What can I use?
> A control required little maintenance.
> lstFolder.additem
> An array needs maintenance.
> instantiate
> ReDim Preserve
> etc.
> I need a fast something.
> Something that will handle up to 100K at least.
> Does not need to be visible.
What's the goal? A ListBox might actually serve it, if this isn't part of a UI.
But you gotta learn to think more like a computer, if you want to tell it what to
do.
> Where can I find the size restrictions for the contrls in VB6SP6?
Here's as good a starting place as any. (You haven't run into one, yet, btw.)
--
..NET: It's About Trust!
http://vfred.mvps.org |
|
| Back to top |
|
 |
Lorin
Joined: 04 Oct 2007 Posts: 312
|
Posted: Wed Feb 27, 2008 10:11 pm Post subject: Re: ListBox Negative Count |
|
|
Aha. I knew someone would know the backdoor.
I'll try it.
"Karl E. Peterson" wrote:
> Lorin wrote:
> > And I guess I should add that I want to add only unique items.
> > The LsitBox was fast and I used the API call to check for existing entry.
> > So the replacement needs to be similar.
>
> Hmmmmm, so you know how to use the API with a listbox? Why, then, are you using VB
> to get an itemcount? (Try LB_GETCOUNT instead.)
> --
> ..NET: It's About Trust!
> http://vfred.mvps.org
>
>
> |
|
| Back to top |
|
 |
Bob Butler
Joined: 04 Oct 2007 Posts: 1081
|
Posted: Wed Feb 27, 2008 10:16 pm Post subject: Re: ListBox Negative Count |
|
|
"Karl E. Peterson" wrote in message @TK2MSFTNGP05.phx.gbl...
> Lorin wrote:
>> VB6SP6
>>
>> I added items to a ListBox and got
>>
>> lstFolders.ListCount returning -32768
>
> Oops, one too many. (Tho some might say, that's a bit of an
> understatement!)
More like about 32468 too many |
|
| Back to top |
|
 |
MikeD
Joined: 04 Oct 2007 Posts: 3348
|
Posted: Thu Feb 28, 2008 1:32 am Post subject: Re: ListBox Negative Count |
|
|
"Lorin" wrote in message @microsoft.com...
> VB6SP6
>
> I added items to a ListBox and got
>
> lstFolders.ListCount returning -32768
>
> I guess I will not use a Listbox.
> But why the negative number?
You added too many items to the listbox (or combobox, but presumably a
listbox given the name)
>
> Why does it not throw an error?
Just due to the way it's designed.
> What can I use?
> A control required little maintenance.
> lstFolder.additem
> An array needs maintenance.
> instantiate
> ReDim Preserve
> etc.
> I need a fast something.
> Something that will handle up to 100K at least.
> Does not need to be visible.
If it doesn't need to be visible, why are you using a ListBox to begin with?
I think you should better explain what you're TRYING to do and what you NEED
to do.
> Where can I find the size restrictions for the contrls in VB6SP6?
They're in VB's Help (MSDN Library). From the Contents tab:
MSDN Library - October 2001
have installed>
--Visual Tools and Languages
-- -- Visual Studio 6.0 Documentation
-- -- --Visual Basic Documentation
-- -- -- -- Using Visual Basic
-- -- -- -- -- Programmer's Guide
-- -- -- -- -- -- Visual Basic Specifications, Limitations, and File Formats
-- -- -- -- -- -- --Project Limitations
-- -- -- -- -- -- -- -- Control Limitations
Or, just click on this link:
http://msdn2.microsoft.com/en-us/library/aa240865(VS.60).aspx
And you'll see:
Property
List and ListCount
Applies to
List box and combo box controls
Limitation
Maximum number of items is 32K; the limit on the size of each item is 1K
(1024 bytes).
There's something to be said for "taking the easy way out" or using
"shortcuts", but sometimes you just gotta write code to do what you need.
I don't mean to be rude or insulting, but if using an array would be too
much "maintenance", then programming is not for you. It really sounds like
you're using a ListBox for this because you're just too lazy to write some
code to handle it.
--
Mike
Microsoft MVP Visual Basic
|
|
| Back to top |
|
 |
|