How do i get class/modules to interact with Usercontrol winsocks. Every time I tried the winsock is not found.
Maybe something like this?:
This is in the UserControl:
Public Sub Winsock(Action as string, Address as string, Port as string)
if Action = "Connect" then
Winsock1.Connect address, port
end if
end sub
Code in the Class/Modules:
UserControl1.Winsock Connect, "bnls.valhallalegends.com", "9367"
Didn't know if this would work, but it does. There is *most likely* an easier way, but this is all I could think of off the top of my head.
I tried that out and it didnt work, first try was just a winsock on a blank usercontrol with a winsock named winsock1 with the code, compiled and it said object not found.
This is in the UserControl:
Public Sub THEWINSOCK(Action as string, Address as string, Port as string)
if Action = "Connect" then
Winsock1.Connect address, port
end if
end sub
Code in the Class/Modules:
UserControl1.THEWINSOCK Connect, "bnls.valhallalegends.com", "9367"
Now that I renamed a few things try it, it might make more sense to you. It works, I tried it.
I'm not sure if this would give the same error as what you are saying, but make sure for the usercontrol that Public = True, I ran into that problem a few times.
I did exactly what you said
Module
Public Function Connection()
UserControl1.THEWINSOCK Connect, "bnls.valhallalegends.com", "9367"
End Function
Usercontrol
Public Sub THEWINSOCK(Action As String, Address As String, Port As String)
If Action = "Connect" Then
Winsock1.Connect Address, Port
End If
End Sub
Private Sub UserControl_Click()
Connection
End Sub
When i type in usercontrol1 then "." no public functions or subs appear in the module and i have control set to public.
When i compile and add to a new exe, i run it and click the drawn ocx area i get Object not found. No clue what im doing wrong.
Quote from: ___/\___ on May 19, 2004, 04:44 PMI did exactly what you said
Module
Public Function Connection()
UserControl1.THEWINSOCK Connect, "bnls.valhallalegends.com", "9367"
End Function
Usercontrol
Public Sub THEWINSOCK(Action As String, Address As String, Port As String)
If Action = "Connect" Then
Winsock1.Connect Address, Port
End If
End Sub
Private Sub UserControl_Click()
Connection
End Sub
When i type in usercontrol1 then "." no public functions or subs appear in the module and i have control set to public.
When i compile and add to a new exe, i run it and click the drawn ocx area i get Object not found. No clue what im doing wrong.
First off, your Action is a string, yet you are not passing a string. Connect should be in string quotes.
Second, you may not know what you're doing wrong, but you don't know what you're doing right, either. What is it precisely that you want to do?
Im trying to have class access a winsock on the usercontrol to send data.
Quote from: ___/\___ on May 19, 2004, 05:08 PM
Im trying to have class access a winsock on the usercontrol to send data.
Is the class owned by the UserControl, or is the class owned by the application which contains the form on which you drop the UserControl?
it is owned by the Usercontrol.
You will need to provide accessor functions in order to access the Winsock within the UserControl. This is because the Winsock control is initialized as a private object module within the UserControl. So you will need to add functions like:
(Inside of the UserControl's code)
Private Sub Connect(Optional ByVal Server As String = "Default Server", Optional ByVal Port As Long = DefaultPort)
Winsock1.Connect Server, Port
End Sub
You will need to provide similar functions for all of the Winsock's functionality that you want to duplicate.
What i was trying to say before is none of my class's or modules coud not access anything public on the usercontrol.
As I just explained, any controls you create within the UserControl container are private object modules.
Are you using the correct name when tryibng to acess the usercontrol?...
I accidently did UserControl1...but there should've been two 1s..(UserControl11)