Q:

VB6 Dynamically Adding Winsock Control

I'm using the following code to dynamically create a WinSock control, and connect to a server using it:
Licenses.Add "MSWinsock.WinSock.1"
Controls.Add "MSWinsock.WinSock.1", "s1"

s1.RemoteHost = "irc.netsplit.de"
s1.RemotePort = "6667"
s1.Connect

However I get "Error 424: Object required.", highlighting "s1.RemoteHost...", how can I fix this? The control should be added from previous lines?
Thanks.

A:

The simplest way is to just dump a socket control to the form to negate the need for importing the license & get strict typing, then;
Controls.Add "MSWinsock.WinSock.1", "s1"

Dim s1 As Winsock: Set s1 = Controls("s1")
s1.RemoteHost = "irc.netsplit.de"

Or perhaps an array of sockets is what your after?

