PDA

Click to See Complete Forum and Search --> : Error using Winsock OCX


msdnexpert
Jun 28th, 2000, 12:02 PM
Hi all,
The following code snippet that I am using in an ActiveX DLL gives me an error and I can't figure out why.

Private WithEvents MySock as Winsock

Private Sub Class_Initialize()
'I get an error message i.e. Error in data type
Set MySock = CreateObject("MSWinsock.Winsock")
End Sub

Private Sub Class_Terminate()
Set MySock = Nothing
End Sub

Wolfie
Jul 6th, 2000, 02:02 AM
hi msdnexpert, try this.

Private WithEvents MySock as Winsock

Private Sub Class_Initialize()
'I get an error message i.e. Error in data type
Set MySock = new Winsock
End Sub

Private Sub Class_Terminate()
Set MySock = Nothing
End Sub

msdnexpert
Jul 7th, 2000, 01:17 AM
Hi Wolfie,
Your code also gives me an error. i.e. Invalid use of new keyword. Any other suggestions.

Wolfie
Jul 10th, 2000, 01:02 AM
Hi, msdnexpert

Did you add a reference to the mswinsock.ocx?

msdnexpert
Jul 11th, 2000, 06:42 AM
Hi Wolfie,
Yes I did add a reference to winsock.ocx. Any suggestions.

Wolfie
Jul 11th, 2000, 07:28 AM
msdnexpert,
Let's try this step by step. If this does not work, then I'm out of ideas.

Open a new project, choose activex dll.
Click on project, references, Browse and select the mswinsck.ocx.
In your declarations section type the following:
Private WithEvents mySock As MSWinsockLib.Winsock
In your class initialize event type the following :
Set mySock = New MSWinsockLib.Winsock

This works on my machine.
Warning: Do not add the control to your components.

Hope it works
Wolfie