Home All Groups Group Topic Archive Search About

Why can't I test class functions from the Immediate window?

Author
9 Oct 2005 7:34 PM
LurfysMa
I am trying to create a DLL file for a bunch of utility functions I
have written.

I created a new ActiveX DLL project.
I created a Class module in that project.
I copied 2-3 functions from another project into the class module.
These are all Public functions.

In the old project, the functions are in regular (.bas) module. There
I am able to test them from the Immediate window.

In the ActiveX project, I have the exact same functions defined, but
when I type a test case in the Immediate window, I get a compile
error: "Sub of Funtion not defined".

Am I doing something wrong or is this how it's supposed to work?



--
For email, use Usenet-20031220@spamex.com

Author
9 Oct 2005 7:48 PM
Steven Burn
http://emsindia.com/Hindi/H2/C854.html
http://www.webdevelopersjournal.com/articles/activex_for_asp.html

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Show quote Hide quote
"LurfysMa" <invalid@invalid.invalid> wrote in message
news:pkoik193i6rak40g0uvhhljn2bsstbpg0d@4ax.com...
> I am trying to create a DLL file for a bunch of utility functions I
> have written.
>
> I created a new ActiveX DLL project.
> I created a Class module in that project.
> I copied 2-3 functions from another project into the class module.
> These are all Public functions.
>
> In the old project, the functions are in regular (.bas) module. There
> I am able to test them from the Immediate window.
>
> In the ActiveX project, I have the exact same functions defined, but
> when I type a test case in the Immediate window, I get a compile
> error: "Sub of Funtion not defined".
>
> Am I doing something wrong or is this how it's supposed to work?
>
>
>
> --
> For email, use Usenet-20031220@spamex.com
Author
9 Oct 2005 8:25 PM
Marv Wade
Steve, I looked at the site you showed in your response to the question.  I
would like to find the first page of these samples but if I try to use an
address with a page lower than the first one shown I get a page not
displayed.

Do you known how I can find any pages lower than the ones shown(751)?

Marv

Show quoteHide quote
"Steven Burn" <somewhere@in-time.invalid> wrote in message
news:uoTH7pQzFHA.2848@TK2MSFTNGP15.phx.gbl...
> http://emsindia.com/Hindi/H2/C854.html
> http://www.webdevelopersjournal.com/articles/activex_for_asp.html
>
> --
> Regards
>
> Steven Burn
> Ur I.T. Mate Group
> www.it-mate.co.uk
>
> Keeping it FREE!
>
> "LurfysMa" <invalid@invalid.invalid> wrote in message
> news:pkoik193i6rak40g0uvhhljn2bsstbpg0d@4ax.com...
>> I am trying to create a DLL file for a bunch of utility functions I
>> have written.
>>
>> I created a new ActiveX DLL project.
>> I created a Class module in that project.
>> I copied 2-3 functions from another project into the class module.
>> These are all Public functions.
>>
>> In the old project, the functions are in regular (.bas) module. There
>> I am able to test them from the Immediate window.
>>
>> In the ActiveX project, I have the exact same functions defined, but
>> when I type a test case in the Immediate window, I get a compile
>> error: "Sub of Funtion not defined".
>>
>> Am I doing something wrong or is this how it's supposed to work?
>>
>>
>>
>> --
>> For email, use Usenet-20031220@spamex.com
>
>
Author
9 Oct 2005 9:09 PM
Steven Burn
The emsindia.com one only seem to have those linked on that page. However
WDJ's ASP article starting point is as;

http://www.webdevelopersjournal.com/hubs/prophub.html#asp

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Show quoteHide quote
"Marv Wade" <N*@columbus.rr.com> wrote in message
news:O0aCW#QzFHA.3812@TK2MSFTNGP09.phx.gbl...
> Steve, I looked at the site you showed in your response to the question.
I
> would like to find the first page of these samples but if I try to use an
> address with a page lower than the first one shown I get a page not
> displayed.
>
> Do you known how I can find any pages lower than the ones shown(751)?
>
> Marv
>
> "Steven Burn" <somewhere@in-time.invalid> wrote in message
> news:uoTH7pQzFHA.2848@TK2MSFTNGP15.phx.gbl...
> > http://emsindia.com/Hindi/H2/C854.html
> > http://www.webdevelopersjournal.com/articles/activex_for_asp.html
> >
> > --
> > Regards
> >
> > Steven Burn
> > Ur I.T. Mate Group
> > www.it-mate.co.uk
> >
> > Keeping it FREE!
> >
> > "LurfysMa" <invalid@invalid.invalid> wrote in message
> > news:pkoik193i6rak40g0uvhhljn2bsstbpg0d@4ax.com...
> >> I am trying to create a DLL file for a bunch of utility functions I
> >> have written.
> >>
> >> I created a new ActiveX DLL project.
> >> I created a Class module in that project.
> >> I copied 2-3 functions from another project into the class module.
> >> These are all Public functions.
> >>
> >> In the old project, the functions are in regular (.bas) module. There
> >> I am able to test them from the Immediate window.
> >>
> >> In the ActiveX project, I have the exact same functions defined, but
> >> when I type a test case in the Immediate window, I get a compile
> >> error: "Sub of Funtion not defined".
> >>
> >> Am I doing something wrong or is this how it's supposed to work?
> >>
> >>
> >>
> >> --
> >> For email, use Usenet-20031220@spamex.com
> >
> >
>
>
Author
10 Oct 2005 6:27 AM
LurfysMa
On Sun, 9 Oct 2005 20:48:46 +0100, "Steven Burn"
<somewhere@in-time.invalid> wrote:

That's essentially what I did the first time.

As Mark pointed out, setting the Instancing property of the Class
module to GlobalMultiUse eliminates the need for the Object variable
and the Set statement. Right?

--
For email, use Usenet-20031220@spamex.com
Author
9 Oct 2005 11:08 PM
MikeD
Show quote Hide quote
"LurfysMa" <invalid@invalid.invalid> wrote in message
news:pkoik193i6rak40g0uvhhljn2bsstbpg0d@4ax.com...
>I am trying to create a DLL file for a bunch of utility functions I
> have written.
>
> I created a new ActiveX DLL project.
> I created a Class module in that project.
> I copied 2-3 functions from another project into the class module.
> These are all Public functions.
>
> In the old project, the functions are in regular (.bas) module. There
> I am able to test them from the Immediate window.
>
> In the ActiveX project, I have the exact same functions defined, but
> when I type a test case in the Immediate window, I get a compile
> error: "Sub of Funtion not defined".
>
> Am I doing something wrong or is this how it's supposed to work?


Short answer is that's how it's supposed to work. Before you can use
anything in a class (property, method, etc.), you need to instantiate an
object from that class. Unless you're running a project and have already
instantiated an object, the Immediate window knows nothing about it (and
even then, the object variable needs to be scope).


--
Mike
Microsoft MVP Visual Basic
Author
9 Oct 2005 11:48 PM
Ralph
Show quote Hide quote
"MikeD" <nob***@nowhere.edu> wrote in message
news:Oo4AJZSzFHA.2348@TK2MSFTNGP15.phx.gbl...
>
> "LurfysMa" <invalid@invalid.invalid> wrote in message
> news:pkoik193i6rak40g0uvhhljn2bsstbpg0d@4ax.com...
> >I am trying to create a DLL file for a bunch of utility functions I
> > have written.
> >
> > I created a new ActiveX DLL project.
> > I created a Class module in that project.
> > I copied 2-3 functions from another project into the class module.
> > These are all Public functions.
> >
> > In the old project, the functions are in regular (.bas) module. There
> > I am able to test them from the Immediate window.
> >
> > In the ActiveX project, I have the exact same functions defined, but
> > when I type a test case in the Immediate window, I get a compile
> > error: "Sub of Funtion not defined".
> >
> > Am I doing something wrong or is this how it's supposed to work?
>
>
> Short answer is that's how it's supposed to work. Before you can use
> anything in a class (property, method, etc.), you need to instantiate an
> object from that class. Unless you're running a project and have already
> instantiated an object, the Immediate window knows nothing about it (and
> even then, the object variable needs to be scope).
>
>
> --
> Mike
> Microsoft MVP Visual Basic
>

Of course if you want to have some ugly fun - you can instantiate the class
in the intermediate window.
set a = new class1: ?a.method

<g>
-ralph
Author
10 Oct 2005 12:16 AM
MikeD
"Ralph" <nt_consultin***@yahoo.com> wrote in message
news:UeadnVfYCJiDMdTenZ2dnUVZ_tGdnZ2d@arkansas.net...

>> Short answer is that's how it's supposed to work. Before you can use
>> anything in a class (property, method, etc.), you need to instantiate an
>> object from that class. Unless you're running a project and have already
>> instantiated an object, the Immediate window knows nothing about it (and
>> even then, the object variable needs to be scope).
>
> Of course if you want to have some ugly fun - you can instantiate the
> class
> in the intermediate window.
> set a = new class1: ?a.method

And that's about all the "fun" you'd have.

BTW, I thought you were going to start "shortening" your quotes?  <g>

--
Mike
Microsoft MVP Visual Basic
Author
10 Oct 2005 12:44 AM
Ralph
Show quote Hide quote
"MikeD" <nob***@nowhere.edu> wrote in message
news:OUZVE$SzFHA.2540@TK2MSFTNGP09.phx.gbl...
>
> "Ralph" <nt_consultin***@yahoo.com> wrote in message
> news:UeadnVfYCJiDMdTenZ2dnUVZ_tGdnZ2d@arkansas.net...
>
> >> Short answer is that's how it's supposed to work. Before you can use
> >> anything in a class (property, method, etc.), you need to instantiate
an
> >> object from that class. Unless you're running a project and have
already
> >> instantiated an object, the Immediate window knows nothing about it
(and
> >> even then, the object variable needs to be scope).
> >
> > Of course if you want to have some ugly fun - you can instantiate the
> > class
> > in the intermediate window.
> > set a = new class1: ?a.method
>
> And that's about all the "fun" you'd have.
>
> BTW, I thought you were going to start "shortening" your quotes?  <g>
>
> --
> Mike
> Microsoft MVP Visual Basic
>

Hey, that one was short. (short for me anyway.)
The others get a grace because it is Sunday. (Yes I play Calvin Ball a lot.
<g>)

-ralph
Author
9 Oct 2005 11:20 PM
Mark Alexander Bertenshaw
Show quote Hide quote
"LurfysMa" <invalid@invalid.invalid> wrote in message
news:pkoik193i6rak40g0uvhhljn2bsstbpg0d@4ax.com...
> I am trying to create a DLL file for a bunch of utility functions I
> have written.
>
> I created a new ActiveX DLL project.
> I created a Class module in that project.
> I copied 2-3 functions from another project into the class module.
> These are all Public functions.
>
> In the old project, the functions are in regular (.bas) module. There
> I am able to test them from the Immediate window.
>
> In the ActiveX project, I have the exact same functions defined, but
> when I type a test case in the Immediate window, I get a compile
> error: "Sub of Funtion not defined".

"LurfysMa" -

VB cannot find your procedures, because it isn't declared in public
namespace.  That is, you can only access a public procedure, function, or
property in a standard BAS module, or from objects which have been mapped
into global scope e.g.  ActiveX DLLs with Global MultiUse classes or
implicit Form objects.

If you want to test the procedures in your class, you can add a new BAS
module, and add a Property Get procedure named something appropriate, which
returns an instance of the class you want to test,  e.g.

Class CGeneralProcedures
----------------------------------------

Public Sub DoSomething()
...
End Sub

Public Sub DoSomethingElse()
...
End Sub

Public Sub DoSomethingMore()
...
End Sub


Module MTest
---------------------

Public Property Get GeneralProcedures() As CGeneralProcedures
    Set GeneralProcedures = New CGeneralProcedures
End Property


Immediate
========

GeneralProcedures.DoSomething
GeneralProcedures.DoSomethingElse
GeneralProcedures.DoSomethingMore



--
Mark Bertenshaw
Kingston upon Thames
UK
Author
10 Oct 2005 3:57 AM
LurfysMa
On Mon, 10 Oct 2005 00:20:27 +0100, "Mark Alexander Bertenshaw"
<mark.bertens***@virgin.net> wrote:

Show quoteHide quote
>"LurfysMa" <invalid@invalid.invalid> wrote in message
>news:pkoik193i6rak40g0uvhhljn2bsstbpg0d@4ax.com...
>> I am trying to create a DLL file for a bunch of utility functions I
>> have written.
>>
>> I created a new ActiveX DLL project.
>> I created a Class module in that project.
>> I copied 2-3 functions from another project into the class module.
>> These are all Public functions.
>>
>> In the old project, the functions are in regular (.bas) module. There
>> I am able to test them from the Immediate window.
>>
>> In the ActiveX project, I have the exact same functions defined, but
>> when I type a test case in the Immediate window, I get a compile
>> error: "Sub of Funtion not defined".
>
>"LurfysMa" -
>
>VB cannot find your procedures, because it isn't declared in public
>namespace.  That is, you can only access a public procedure, function, or
>property in a standard BAS module, or from objects which have been mapped
>into global scope e.g.  ActiveX DLLs with Global MultiUse classes or
>implicit Form objects.

Setting the Global Multiuse property solved most of the problems.
Thanks for that suggestion.

>If you want to test the procedures in your class, you can add a new BAS
>module, and add a Property Get procedure named something appropriate, which
>returns an instance of the class you want to test,  e.g.

I'll check that out.

Show quoteHide quote
>Class CGeneralProcedures
>----------------------------------------
>
>Public Sub DoSomething()
> ...
>End Sub
>
>Public Sub DoSomethingElse()
> ...
>End Sub
>
>Public Sub DoSomethingMore()
> ...
>End Sub
>
>
>Module MTest
>---------------------
>
>Public Property Get GeneralProcedures() As CGeneralProcedures
>    Set GeneralProcedures = New CGeneralProcedures
>End Property
>
>
>Immediate
>========
>
>GeneralProcedures.DoSomething
>GeneralProcedures.DoSomethingElse
>GeneralProcedures.DoSomethingMore


--
For email, use Usenet-20031220@spamex.com
Author
10 Oct 2005 2:35 PM
Ken Halter
"LurfysMa" <invalid@invalid.invalid> wrote in message
news:pkoik193i6rak40g0uvhhljn2bsstbpg0d@4ax.com...
>
> In the old project, the functions are in regular (.bas) module. There
> I am able to test them from the Immediate window.

Just wait until you try to use the .Net immediate window.... LO<freaking>L
(some would say... what immediate window?)

> In the ActiveX project, I have the exact same functions defined, but
> when I type a test case in the Immediate window, I get a compile
> error: "Sub of Funtion not defined".
>
> Am I doing something wrong or is this how it's supposed to work?

You have to create instances of any class modules you use... and, imo, the
ability to debug in the immediate window is not enough to get me to use
GlobalMultiUse (memory leaks waiting to happen). Instead, create a Standard
EXE test app to exercise the class.

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Please keep all discussions in the groups..