Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#185594 - 20/10/2003 15:31 activex vb user controls and class modules
RobotCaleb
pooh-bah

Registered: 15/01/2002
Posts: 1866
Loc: Austin
ive a particular function residing in a class module that i really would like to call from my user control. now, i might be missing something, but its not working. what im trying to call looks like this
PassedString = EncryptString(PassedString)



the class module that holds 'EncryptString()' lies in a file called Encryption.cls with a Name field of Encryption.
i believe i could prolly move everything from the class into the control, but then that defeats the point of having a module in the first place.
thanks.


Edited by customsex (20/10/2003 15:38)

Top
#185595 - 20/10/2003 15:41 Re: activex vb user controls and class modules [Re: RobotCaleb]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31594
Loc: Seattle, WA
but its not working
Can you more clearly define "not working"?
_________________________
Tony Fabris

Top
#185596 - 20/10/2003 15:48 Re: activex vb user controls and class modules [Re: tfabris]
RobotCaleb
pooh-bah

Registered: 15/01/2002
Posts: 1866
Loc: Austin
ahh yes, my bad
Sub or Function not defined.
on the aforementioned line

Top
#185597 - 20/10/2003 15:51 Re: activex vb user controls and class modules [Re: RobotCaleb]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31594
Loc: Seattle, WA
Make sure the function in the class module is defined as Public?
_________________________
Tony Fabris

Top
#185598 - 20/10/2003 15:55 Re: activex vb user controls and class modules [Re: tfabris]
RobotCaleb
pooh-bah

Registered: 15/01/2002
Posts: 1866
Loc: Austin
yeah, first thing i checked.

Top
#185599 - 20/10/2003 15:57 Re: activex vb user controls and class modules [Re: RobotCaleb]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31594
Loc: Seattle, WA
What's the definition line for EncryptString look like?
_________________________
Tony Fabris

Top
#185600 - 20/10/2003 16:00 Re: activex vb user controls and class modules [Re: tfabris]
RobotCaleb
pooh-bah

Registered: 15/01/2002
Posts: 1866
Loc: Austin
Public Function EncryptString(StringToEncrypt As String, Optional Key As String, Optional OutputInHex As Boolean) As String

Top
#185601 - 20/10/2003 16:05 Re: activex vb user controls and class modules [Re: RobotCaleb]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31594
Loc: Seattle, WA
Does it work if you put it in a BAS module instead of a class module?
_________________________
Tony Fabris

Top
#185602 - 20/10/2003 16:06 Re: activex vb user controls and class modules [Re: tfabris]
RobotCaleb
pooh-bah

Registered: 15/01/2002
Posts: 1866
Loc: Austin
i can try. the file it currently resides in is Encryption.cls
it works fine called when compiled into a dll. ill try your suggestion.

Top
#185603 - 20/10/2003 16:08 Re: activex vb user controls and class modules [Re: tfabris]
RobotCaleb
pooh-bah

Registered: 15/01/2002
Posts: 1866
Loc: Austin
no

'Events

Event Progress(Percent As Long)
Compile error:
Only valid in object module

Top
#185604 - 20/10/2003 16:14 Re: activex vb user controls and class modules [Re: RobotCaleb]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31594
Loc: Seattle, WA
Well, I'm stumped. Any time I see "function not defined" for a function I'm sure that I've defined, it always comes down to a silly syntactical error or something. Like, I've called it a sub when I meant a function, or some such. Look for that kind of thing first. Also, when it has "sub or function not defined" on your screen, press F1 and it'll list all the reasons that the error might appear.
_________________________
Tony Fabris

Top
#185605 - 21/10/2003 03:30 Re: activex vb user controls and class modules [Re: RobotCaleb]
number6
old hand

Registered: 30/04/2001
Posts: 745
Loc: In The Village or sometimes: A...
Try setting the properties of your class to "Global MultiUse".
[right click on the Class file in the Project Explorer window, then go Properties - you set the "instancing" property there - change it to Global Multiuse from what it is now].

This setting will let your code call the "methods" in the class [e.g. EncryptString] *AS IF* you had already instanced the class and were calling the methods the usual "COM way".

You may have to go Classname.EncryptString(...) in your code where Classname is the "class" name of the .CLS file rather than just "Encryptstring" [see the properties of the .CLS file in Project Explorer for the Classname it has - usually its the same as the .CLS file, "base" filename (sans the .CLS extension), but can be different if you so decide to make it different].

Either of both of these should solve your problem.

Note, as the .cls file is a VB Class, you have to do it this way.
If you want to call EncryptString without needing to instance it or fiddle with Instancing parameters, then move all the code from in EncryptString into a Public Function in the ".bas" (module) file, and have EncryptString call this function (merely being a "wrapper" for the module function).






Top