Index, multiple items

hys

Newcomer
Joined
Apr 10, 2003
Messages
7
Hello all,

Just a quick question ... I used to be able to use indexs in VB 6 to dynamically recreate and item ... but there are no indexs in VB.NET

help !!!

say i have a winsock control .. named ... wSck ... how do i get wSck(0) and wSck(1) and so on...
 
You can still declare
dim wSck(Nbr) as YourClass

but you'll have to create an instance before using each
wSck(i)=new YourClass()

So you don't have indexing at design for windows form controls too but you can achieve the same:
dim myTextBoxes(nbr) as textbox
Visual Basic:
for i =0 to nbr-1
     myTextBoxes(i) = New Textbox()
     With myTextBoxes(i)
         .height=
         .width=
         .top=
         addhandler...
    End With
next
 
Last edited:
but how do i replicate a control that is already on the form

at the moment i have a winsock control on the form, with the defaulted parameters...

therefore i would like to make two instances of the control...
 
to my knowledge, the best way to replicate a control by creating a new instance of it and have some init proc set its parameters. wSck(i)=myExistingwSck wouldnt work.
They are many ways to achieve this. Create an inherited class and have its constructor do the job.Then add a new instance to an arraylist, create an array of them,... your choice.......
OR Do as i mentionned earlier if you have to create an array once or..Or..or....there are probably as many ways as programmers..
 
Last edited:
It's worth mentioning that if this is the old VB6 Winsock control you're talking about, you really shouldn't be using it in .NET - That's what the Socket and TcpClient classes are for.
 
Back
Top