[英]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? 鉴于可以在VB脚本中定义一个类,有没有办法为该类指定默认属性?
eg 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? 无论如何我可以说
Name
是默认属性吗?
NB: To do this in VB6, one would add an attribute to the property, but this doesn't work in VbScript 注意:要在VB6中执行此操作,可以向属性添加属性,但这在VbScript中不起作用
Public Property Get Name()
Attribute Name.VB_MemberFlags = "200"
Name = strName
End Property
Use the Default
keyword: 使用
Default
关键字:
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: 编辑:这里有一些关于在VBScript中使用类的教程和参考文章,希望你会发现它们很有用:
Starting Object Oriented Programming in VBScript 在VBScript中启动面向对象的编程
VBScript in a Nutshell. 简洁的VBScript。 Chapter 2: Program Structure (section Class Modules )
第2章:程序结构 ( 类模块部分)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.