I want to create my own components to use on my website, however I am not sure how to get the WINSOCK OCX component into my class module.. Any idea's? I'm sure everyone has run into the problem one time or another.
The following code snippet will allow you to create and use a winsock control in your class module. First create a form called frmWsk and place a Winsock control on this form (named Winsock1 in the example). In the class module, create a module level var that references a winsock object. In the class initialize event, set the variable to the Winsock control on the form. From then on, in your class, reference the var name (wskNet) just as you would a winsock control on a form. All properties can be set, methods called etc.
Because it is declared WithEvents, the events raised by the object can even be handled in the class module. If you go to your object pull down in the IDE, you will notice you get an object named wskNet. When this is selected, the events list in the IDE gives you all of the events you would normally get with the winsock control.
' Object decraration (before any code in class module)
Dim WithEvents wskNet As Winsock
' Class module initialize event
Private Sub Class_Initialize()
Set wskNet = frmWsk.Winsock1 ' Creates ref to control
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.