classes in vbscript

R

Roy Danon

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.
 
B

Bob Barrows [MVP]

Roy said:
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
 
B

Bob Barrows [MVP]

Bob said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top