For Programmers: Free Programming Magazines  


Home > Archive > ASP > March 2005 > classes in vbscript









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author classes in vbscript
Roy Danon

2005-03-30, 3:57 am

Hi,
i'm trying to create a class which one of its properties is another class.


this is what i'm basicly trying to do :

public bbb
public aaa
end class

class bugi
public ccc as new subbugi
public ddd
end class

set a=new bugi
a.ccc.aaa="ds"


the problem is that for somereason this doesn't work.
any solutions?


Roy.


Bob Barrows [MVP]

2005-03-30, 8:55 am

Roy Danon wrote:
> Hi,
> i'm trying to create a class which one of its properties is another
> class.
>
>
> this is what i'm basicly trying to do :
>
> public bbb
> public aaa
> end class
>
> class bugi
> public ccc as new subbugi


This is not legal in vbscript where all variables are variants.

Besides, I don't see where the subbugi class is defined. Are we supposed to
assume it's defined somewhere? Oh wait! Was "public bbb" supposed to be
"class subbugi"? If so, this may work:

private _ccc
public Property Get ccc
set ccc=_ccc
End Property
Private Sub Class_Initialize
Set _ccc=New subbugi
End Sub


> public ddd
> end class
>
> set a=new bugi
> a.ccc.aaa="ds"
>
>
> the problem is that for somereason this doesn't work.
> any solutions?
>


What does "doesn't work" mean? Error messages? Machine freezes?

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Bob Barrows [MVP]

2005-03-30, 8:55 am

Bob Barrows [MVP] wrote:
> If so, this may work:
>
> private _ccc
> public Property Get ccc
> set ccc=_ccc
> End Property
> Private Sub Class_Initialize
> Set _ccc=New subbugi
> End Sub
>
>

Hmm, I overthought that one. This should be all that you need:

Public ccc
Private Sub Class_Initialize
Set ccc=New subbugi
End Sub


Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com