|
-
Jan 27th, 2004, 12:49 PM
#1
Thread Starter
Addicted Member
array with "withevents"
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
-
Jan 27th, 2004, 01:54 PM
#2
Frenzied Member
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.
-
Jan 27th, 2004, 01:55 PM
#3
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.
-
Jan 27th, 2004, 02:18 PM
#4
Thread Starter
Addicted Member
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
-
Jan 27th, 2004, 05:11 PM
#5
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|