Click to See Complete Forum and Search --> : Creating an array of controls


Salt
March 17th, 1999, 04:04 AM
It might sound like a imple question, but when you have no help files, its a bit of a handicap.


How would I go about creating an array of winsock controls? I want to have multiple clients connect to a server, and throwing a bunch of individual winsock controls on a form seems like a lot of repeated code.


Salt

James Grant
April 1st, 1999, 04:08 PM
Create 2 controls on the form.
Change the (name) of the second control to the first one.
It will ask you if you want to create a control array (say yes).
They are now distinguished by the Index property.
You can just continue this process.

Note: if you just copy an existing control on a form and paste it, it will do the same thing (so you don't have to change the name of each new one manually).

Ravi Kiran
April 1st, 1999, 07:38 PM
Hi,

Try the usual method for creating Control arrays.
Should work, unless something special about 'Winsock' controls.

The standard method is like this: Lets say a command button (CBtn1):
Add one btn to the form. Change the name to CBtn1 (for ex).
Then change the index property to 0.
This will change the name to CBtn1(0). and you have a control array.
Creating multiple run-time instances is like this:
for i = 1 to 10 ' gives you 11 btns, 0-already exists
Load CBtn1(i) ' creates an ith instance.
' here yoe need to set the properties...
' specially .Visible for this case.
Cbtn(i).Move ....
CBtn(i).Visible = true
next i

Try the same. If it doesn't work, then winsock is a different animal :-)

Ravi