Author | Message | Time |
---|---|---|
______ | How do i get class/modules to interact with Usercontrol winsocks. Every time I tried the winsock is not found. | May 18, 2004, 10:59 PM |
CrAz3D | Maybe something like this?: This is in the UserControl: [code] 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] Code in the Class/Modules: [code] UserControl1.Winsock Connect, "bnls.valhallalegends.com", "9367" [/code] 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. | May 19, 2004, 4:43 PM |
______ | 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. | May 19, 2004, 5:37 PM |
CrAz3D | This is in the UserControl: [code] 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] Code in the Class/Modules: [code] UserControl1.THEWINSOCK Connect, "bnls.valhallalegends.com", "9367" [/code] Now that I renamed a few things try it, it might make more sense to you. It works, I tried it. | May 19, 2004, 7:28 PM |
Flame | 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. | May 19, 2004, 9:13 PM |
______ | I did exactly what you said Module [code] Public Function Connection() UserControl1.THEWINSOCK Connect, "bnls.valhallalegends.com", "9367" End Function [/code] Usercontrol [code] 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 [/code] 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. | May 19, 2004, 9:44 PM |
Grok | [quote author=___/\___ link=board=31;threadid=6868;start=0#msg60847 date=1085003093]I did exactly what you said Module [code]Public Function Connection() UserControl1.THEWINSOCK Connect, "bnls.valhallalegends.com", "9367" End Function[/code] Usercontrol [code]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[/code] 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] 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? | May 19, 2004, 10:01 PM |
______ | Im trying to have class access a winsock on the usercontrol to send data. | May 19, 2004, 10:08 PM |
Grok | [quote author=___/\___ link=board=31;threadid=6868;start=0#msg60852 date=1085004506] Im trying to have class access a winsock on the usercontrol to send data. [/quote] 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? | May 19, 2004, 11:36 PM |
______ | it is owned by the Usercontrol. | May 19, 2004, 11:37 PM |
AntiFlame | 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) [code] Private Sub Connect(Optional ByVal Server As String = "Default Server", Optional ByVal Port As Long = DefaultPort) Winsock1.Connect Server, Port End Sub [/code] You will need to provide similar functions for all of the Winsock's functionality that you want to duplicate. | May 20, 2004, 11:07 PM |
______ | What i was trying to say before is none of my class's or modules coud not access anything public on the usercontrol. | May 20, 2004, 11:59 PM |
AntiFlame | As I just explained, any controls you create within the UserControl container are private object modules. | May 21, 2004, 4:05 AM |
CrAz3D | Are you using the correct name when tryibng to acess the usercontrol?... I accidently did UserControl1...but there should've been two 1s..(UserControl11) | May 21, 2004, 3:24 PM |