|
-
May 29th, 2000, 04:18 AM
#1
If I use listboxes and file list boxes to do things for me that you could actually write in code....like alphabetizing a list or something, is it more work for the program to do?
I frequently put a list of strings in a listbox just so I can set the sorted property to true. Then I get a alphabetized list of strings, just like that. Every solution I have seen in code takes far more lines of code to do the same thing. I just make sure the visible property of the listbox is set to false so the listbox never shows.
Any comments on the way I am doing business? If there is something wrong with it, then I want to start doing it differently so I don't get in a bad habit.
-
May 29th, 2000, 04:37 AM
#2
Guru
Depends how you look at it.
Behind the scenes with the ListBox, it's very ugly.
The little file called MSVBVMnn.DLL does a bunch of stuff which you aren't even aware about.
First, it has to use CreateWindowEx one extra time. Also, it creates another SubClass instance for the new ListBox. It has to answer every Windows/ListBox message it receives.
Then, you set the Sorted to True. This passes a value to some unknown location in memory, which only VB should even be aware of, which triggers an entire routine which runs the sorting algorithm. Then, it has to update that memory, and it does that in unconventional ways (well, you know Microsoft)... Finally, you have to call a relatively large routine more than once in order to pass all the strings back to their locations in your array.
If you don't use a ListBox...
You do a routine which runs the sorting algorithm.
Both do the same thing, basically. Run an algorithm. Except one tells the runtime to do all the work for it, and the other does the work itself.
Technically, it's faster to not use a ListBox for something like that. But, if you have a small collection of strings (today, small is under 10,000), then, with today's GHZ Processors and GB's of RAM (both are almost in every home! Almost in mine, almost in my friends', almost in my relatives'...) it's identical.
-
May 29th, 2000, 06:50 AM
#3
Fanatic Member
I would tend to get out of the habbit if I were you. The fact that you noticed this yourself shows that you sense something is wrong.
Working in memory with data types is always faster. When I started VB a few years back I had some horrible habbits (use RTF boxes for the find() function etc) and I found later with other projects that these methods couldn't cope. I don't mean 10-20% speed increase, I mean 200-1000% increase. looping the RTF_Find() and looping instr() 100,000 times is not the same thing at all. (I understand that that was my prob not yours though )
It's worth understanding how sorting works in code, and using different lists in memory. you will find more and more often that you need to do it without the listbox anyway.
Remember the less controls you use the smaller you app will be to distribute (ocx'x and dlls) and the faster it will be.
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
May 29th, 2000, 11:17 AM
#4
Thanks, I really do value your opinions. It seems that in the end it is worth the extra time from what you guys say. Thanks for giving me some insight.
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
|