grouping in visual basic

D

Thread Starter

didier

hi!

i am doing a screen display using vb in order to demonstrate how my PLC controls the process i am automating. I am showing how the different valves in my process are activated by changing there background colour. Actually i am using lines (lne) to draw the different valves on my vb form (frm). Actually i am using 4 lines to draw one valve, i want to know if i can group these 4 lines on vb to make them as ONE object? or is there another way to do this?
thank you.
 
I don't know of a way to group them but you can make a control array.. Just put one control (line) on the form and copy it, when you paste it it will ask if you would like to make the control an array.
Say yes.. Then when you ref them later in the code it would be like this..
For I = 0 to X <- number of controls in the array -1
line(I).forecolor= vbred
next I
You could use valve1 as the control name if you like and you would have valve1(0), valve1(1)..... for valve1.. then valve2.. yada yada yada.. Have fun..
 
using control arrays is the "pro" way of accomplishing this, but an "easier" way may be to copy and paste all the lines/valves that you have, then draw individual shape controls that sit in front of the valves. with the fill style set to "opaque" and the fill color set to the form color (or background color), simply making these "masks" visible or not has the appearance of toggling visibility of the valves.

very handy technique for lots of other applications too.

chuck
 
Best overall, is to make a custom control. give the custom control whatever properties, you need, like the value to display in the (containted) label control, and assign that property on your host form.

Then in the custom control's "resize" event, you can put the code for resizing and arranging the contained shapes. That way, your "barrel" indicator will always look like a barrel.

(I think if you look around, you can find a VB extension which will rewrite your resize event code for you.)

You can even put arrays of custom controls on a form, which is a lot easier to manage than a whole bunch of individual lines, shapes, labels, and text boxes!
 
Top