开发者

How to designate a property as the Default Property for a VbScript class

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


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:

  • Creating Classes with VBScript

  • Using Classes in VBScript

  • Creating Your Own Classes

  • Starting Object Oriented Programming in VBScript

  • VBScript in a Nutshell. Chapter 2: Program Structure (section Class Modules)

  • Using Classes within VBScript

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜