Compile Error: New Winsock

Compile error:

Private Sub Class_Initialize()
   Set theSock = New Winsock   <------error
End Sub

"Compile error: Invaild use of New keyword"

I have another Form that has another Winsock control, do you think this caused the problem? How can I fix this?
Thank You!


raymng
RaymondAsked:
Who is Participating?
 
bfeddishConnect With a Mentor Commented:

Sounds like you want to use a library instead of a control but why don't you just pass the class a pointer to a winsock control that's on your form?
0
 
bfeddishCommented:

Are you sure you are using the New keyword to instatiate the winsock in your working application?  If you are using the built in control there is no need to instantiate it.
0
 
RaymondAuthor Commented:
bfeddish,

Class Module:
---------------------------------
Private Sub Class_Initialize()
  Set theSock = New Winsock   <------error
End Sub

Main Form:
---------------------------------
I have placed another Winsock control on the main form.


raymng
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
bfeddishCommented:

Is theSock the control name?
0
 
RaymondAuthor Commented:
No, the Winsock control located in the Main Form is called sckDn.
0
 
bfeddishCommented:

If I'm not mistaken, you can just start using the control referenced by it's name. For example sckDn.Connect(), etc. I don't think you need to instantiate another reference to it.
0
 
RaymondAuthor Commented:
bfeddish:

I need two different Winsock, sckDn is on the Main Form whereas theSock is on the class module. I can use sckDn without problem, but theSock has problem.

Class Module:
---------------------------------
Private Sub Class_Initialize()
 Set theSock = New Winsock   <------error
End Sub


raymng
0
 
RaymondAuthor Commented:
Thanx very much!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.