views:

13

answers:

1

Given that one can define a class in VB Script, is there any way to specify a default property for that class?

e.g. Given

Class MyClass
    Private myName 

    Public Property Get Name() 
        Name = myName
    End Property
end class 

Is there anyway I can say that Name is the default property?

NB: To do this in VB6, one would add an attribute to the property, but this doesn't work in VbScript

Public Property Get Name() 
    Attribute Name.VB_MemberFlags = "200"
    Name = strName
End Property
+1  A: 

Use the Default keyword:

Public Default Property Get Name
    Name = myName
End Property

Edit: Here're some tutorial and reference articles about using classes in VBScript, hope you'll find them useful:

Helen
Excellent! Works a treat, thanks a million :)
Binary Worrier
Helen, if I may ask, have you a reference for the classes end of VbScript? All I know are fragments picked up in odds and ends. Thanks.
Binary Worrier
@Binary: Added article links to the answer.
Helen