msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ListBox Negative Count

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB General Discussions
Author Message
Lorin



Joined: 04 Oct 2007
Posts: 312

PostPosted: Wed Feb 27, 2008 9:49 pm    Post subject: ListBox Negative Count Reply with quote

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
View user's profile Send private message
Lorin



Joined: 04 Oct 2007
Posts: 312

PostPosted: Wed Feb 27, 2008 9:52 pm    Post subject: RE: ListBox Negative Count Reply with quote

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
View user's profile Send private message
Karl E. Peterson



Joined: 04 Oct 2007
Posts: 4836

PostPosted: Wed Feb 27, 2008 9:59 pm    Post subject: Re: ListBox Negative Count Reply with quote

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
View user's profile Send private message
Karl E. Peterson



Joined: 04 Oct 2007
Posts: 4836

PostPosted: Wed Feb 27, 2008 9:58 pm    Post subject: Re: ListBox Negative Count Reply with quote

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
View user's profile Send private message
Lorin



Joined: 04 Oct 2007
Posts: 312

PostPosted: Wed Feb 27, 2008 10:11 pm    Post subject: Re: ListBox Negative Count Reply with quote

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
View user's profile Send private message
Bob Butler



Joined: 04 Oct 2007
Posts: 1081

PostPosted: Wed Feb 27, 2008 10:16 pm    Post subject: Re: ListBox Negative Count Reply with quote

"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
View user's profile Send private message
MikeD



Joined: 04 Oct 2007
Posts: 3348

PostPosted: Thu Feb 28, 2008 1:32 am    Post subject: Re: ListBox Negative Count Reply with quote

"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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    msvisual.com Forum Index -> VB General Discussions All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group