• Welcome to Valhalla Legends Archive.
 

help on Usercontrols

Started by ______, May 18, 2004, 05:59 PM

Previous topic - Next topic

______

How do i get class/modules to interact with Usercontrol winsocks. Every time I tried the winsock is not found.

CrAz3D

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.
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

______

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.

CrAz3D


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.
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Flame

#4
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.

______

#5
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.

Grok

#6
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.

Grok

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.

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)

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.

AntiFlame

As I just explained, any controls you create within the UserControl container are private object modules.

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)
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...