Results 1 to 6 of 6

Thread: Error using Winsock OCX

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    266

    Cool

    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

  2. #2
    New Member
    Join Date
    Jun 2000
    Location
    South Africa, Centurion
    Posts
    8
    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    266
    Hi Wolfie,
    Your code also gives me an error. i.e. Invalid use of new keyword. Any other suggestions.

  4. #4
    New Member
    Join Date
    Jun 2000
    Location
    South Africa, Centurion
    Posts
    8
    Hi, msdnexpert

    Did you add a reference to the mswinsock.ocx?

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    266
    Hi Wolfie,
    Yes I did add a reference to winsock.ocx. Any suggestions.

  6. #6
    New Member
    Join Date
    Jun 2000
    Location
    South Africa, Centurion
    Posts
    8
    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

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