Trying to use a collection with a VB standard control but have reached the frustrations point. Any takers to try and correct this sample so I can see what I'm doing wrong.
Thanks
David
Printable View
Trying to use a collection with a VB standard control but have reached the frustrations point. Any takers to try and correct this sample so I can see what I'm doing wrong.
Thanks
David
I think you need to explain yourself a bit more here.
From what I can see, you are creating a collection based on a control, and then trying to use properties that are not in that control. If this is the case, you need to add properties to the control.
What errors are you getting, and where??
Cheers
Thanks for responding gotcha_crazy:
Previously I've only used collections with user defined objects (classes).
What I'm trying to do is try and make a collection for VB controls in lieu of using a control array (which I understand NET has eliminated) to see if it offers any benefits. Also don't want to use VB's Forms or Controls collections.
I recognize collections are slow (as compared to arrays, hash tables) but for a few controls the hit should be small.
---------------------
From what I can see, you are creating a collection based on a control, and then trying to use properties that are not in that control. If this is the case, you need to add properties to the control
----------------------
Since VB controls are predefined by say Microsoft, then IMHO the
properties are already defined by the object (my example picturebox).
Normally you use Load/Unload to deal with a VB control instead of new, but I tried it both ways in the collection and received errors.
Played with the example for several hours prior to post.
If you have the time, would appreciate you trying to see if you can get the example to work and repost it so I can see what I'm doing incorrectly.
Thanks
David
bump
First, I won't answer any of your questions - just explain a bit about the forum.
Putting keywords in [] brackets makes for "quoting" and "code" and "vbcode" and other "visually pretty" formatting.
If you do [quote] it will start a quote - [Highlight=VB] will start visual basic code. That's what the "buttons" on the posting form do.
Putting [/code] ends a CODE paragraph.
At any rate, form controls are "stored" in a collection inside of VB. VB is very collection oriented - .NET lost that, since it's a weak presentation of true objects.
Based on your post count, you've been at this a while - so what are you really trying to understand here??
I do so love it when pple ramble on about nothing and post a totally unnecessary post.
Firstly, it is quite obvious what square braces do, all forums work the same, and they are explained in the help section, which anyone with any savvy would read.
Secondly, it is quite clear what is wanted, as it is posted above.
I hope this wasn't a completely pointless post.
Damn, she's right, I do get defensive!!!
The little homegrown ----- line for "quoting" made me post about the quote and code keywords.Quote:
Originally posted by gotcha_crazy
I do so love it when pple ramble on about nothing and post a totally unnecessary post.
Firstly, it is quite obvious what square braces do, all forums work the same, and they are explained in the help section, which anyone with any savvy would read.
Secondly, it is quite clear what is wanted, as it is posted above.
I hope this wasn't a completely pointless post.
Damn, she's right, I do get defensive!!!
And I sure don't understand the goal to this one...
?? Collection of VB controls ?? They are in a collection - that's the CONTROLS collection - am I missing something? Control array vs. collection? Control arrays reduce the need to have redundant "event code" for similar controls - right?Quote:
What I'm trying to do is try and make a collection for VB controls in lieu of using a control array (which I understand NET has eliminated) to see if it offers any benefits. Also don't want to use VB's Forms or Controls collections.
I couldn't get the downloaded code to run - project failed for me - but it was a bit late for me to start messing around with something like this...
And maybe she is right :D
szlamany
First re: the home grown code "----------------" .
Aren't we getting picky!!!!!! Didn't realize it needed to be in brackets, since no code, just text involved. Like programming there is 100 different ways to resolve the problem.
Re: My question
VB Code:
quote: -------------------------------------------------------------------------------- What I'm trying to do is try and make a collection for VB controls in lieu of using a control array (which I understand NET has eliminated) to see if it offers any benefits. Also don't want to use VB's Forms or Controls collections. --------------------------------------------------------------------------------
I'm currently coding an MDI App with multiple child forms. The user has a menu option to add/remove mulitiple pictureboxes dynamically on each child. Since I eventually plan to port this to NET, I am trying to avoid control arrays as "I understand NET no longer supports them".
I also find the Controls Collection very unwieldy when trying to identify just the Picture boxes of interest and ignore other controls such as the Scrollbar and other Pictureboxes to manipulate sprites.
So, my idea was to create a control collection to just handle pictureboxes of interest. However, for whatever reason I'm having difficulty.
SO -- since you indicate you understand collections extremely well, how about educating me (and I'm sure others) by posting some code whether it be using the Control Collection or a separate collection.
VB Code:
************************
gotcha_crazy
Thanks for the response and support.
David
Control array offer a benefit in VB, since the "event code" behind each control is not duplicated. That helps the developer (less code) and the computer (smaller .exe size).
We have only one VB app that we produce for income - it's an MDI parent with little children forms that procreate control objects at runtime - obviously all in a control array, since that's the only way in traditional VB to have a single event handle the control.
And, I far from understand collection best...
Only been at VB for two years now - programming mainframe/mini computers for 2 decades before that...
szlamany
I guess a number of us old programmers around the forum.
I wrote my first code (FORTRAN) in 1969.
Still not sold on OPP.
While all objects are just like any data type taking up a block of memory, believe the industry could have more easily implemented by just letting the programmer allocate a memory block, reference or point to it with some variable, and then just use that variable rather than all this BS about objects.
Since haven't played with NET so not sure what I'm up against if I try and port this to NET. While from my understanding control arrays have dropped out, I believe (hope) they still have indexes associated with each control for whatever workaround I come up with -- be it arrays, hash tables, or collections.
David
To us here - it's all about the code.
We came from a life of 400+ separate BASIC programs and decided we wanted to go forth with just one program. Supporting that mess was a 24/7 nightmare...
So, we decided to have FORM code be identical from form to form. We actually wrote a little program to compare one form to the next to make sure the code was line by line exact.
With that said, control array interested us alot - since the code behind each "indexed" object was the same. So indexing of the control was just like array access to us - we married our control array index into other arrays...
But I'm rambling now - it's 9:30 here and I wake up at 5:00 every morning thinking about what code I have yet to deliver....