how can i create an array of socket objects using the events of it??
Dim WithEvents sc() As SocketsClient
this line of code VS.Net says that it can't be done, but should be some way!
Thank you,
Guilherme Costa
Printable View
how can i create an array of socket objects using the events of it??
Dim WithEvents sc() As SocketsClient
this line of code VS.Net says that it can't be done, but should be some way!
Thank you,
Guilherme Costa
I'd recommend reading the examples provided with VS titled something like "Asynchronous Socket Server Example" and the client examples. Things are quite a bit different.
If you search the forum, you'll find a bunch of info, including at least one tutorial link posted within the past couple of days.
The VS IDE is right you can't. You should probably make a collection of sockets and encapsulate any events into that. This is where the AddHandler functionality comes in.
Edneeis, great solution, but do you have some document describing how to do that? I'm never did it!!
Thank you a lot,
Guilherme Costa
No I don't really have any documentation for you just look up the help info on the AddHandler function. Here is the quick idea though:
VB Code:
Public Class ButtonEventCollection Inherits CollectionBase Public Event Click As EventHandler 'implement your collection here Protected Overrides Sub OnInsertComplete(ByVal index As Integer, ByVal value As Object) Dim btn As Button = CType(value, Button) AddHandler btn.Click, ClickEvent End Sub Protected Overrides Sub OnRemoveComplete(ByVal index As Integer, ByVal value As Object) Dim btn As Button = CType(value, Button) RemoveHandler btn.Click, ClickEvent End Sub End Class