Results 1 to 5 of 5

Thread: array with "withevents"

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Location
    Porto Alegre, RS
    Posts
    210

    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

  2. #2
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    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.

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Location
    Porto Alegre, RS
    Posts
    210
    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

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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:
    1. Public Class ButtonEventCollection
    2.     Inherits CollectionBase
    3.  
    4.     Public Event Click As EventHandler
    5.  
    6.     'implement your collection here
    7.  
    8.     Protected Overrides Sub OnInsertComplete(ByVal index As Integer, ByVal value As Object)
    9.         Dim btn As Button = CType(value, Button)
    10.         AddHandler btn.Click, ClickEvent
    11.     End Sub
    12.  
    13.     Protected Overrides Sub OnRemoveComplete(ByVal index As Integer, ByVal value As Object)
    14.         Dim btn As Button = CType(value, Button)
    15.         RemoveHandler btn.Click, ClickEvent
    16.     End Sub
    17.  
    18. 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
  •  



Click Here to Expand Forum to Full Width