请教高手:VBScript classes

luco 2003-03-03 11:40:10
我用VBScript engine 5.6 来create 一个Class A 和一个Class B
代码如下:
<%
Class A
private mName
Public Property Get name()
name = mName
End Property

Public Property Let name(pName)
mName = pName
End Property
End Class

Class B
private objA
Private Sub Class_Initialize()
Set objA = New A
End Sub

Public Property Get A()
Set A = objA
End Property

Public Property Let A(pObjA)
Set objA = pObjA
End Property

End Class

dim objTest
Set objTest = new B
%>

问题是:老是说
Error Type:
Microsoft VBScript runtime (0x800A01FA)
Class not defined: 'A'
错误代码在 Class_Initialize 里面,请问为什么?? 当我把
Public Property Get A()
Set A = objA
End Property

Public Property Let A(pObjA)
Set objA = pObjA
End Property
注释掉后,就没有错,搞不清楚应该如何做。拜托各路大虾,小弟在线等待...
...全文
20 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
saucer 2003-03-04
  • 打赏
  • 举报
回复
vbscript does not allow you to use a class name as other class' property name
saucer 2003-03-04
  • 打赏
  • 举报
回复
you are using "A" as the property name in class B, try

<%
Class A
private mName
Public Property Get name()
name = mName
End Property

Public Property Let name(pName)
mName = pName
End Property
End Class

Class B
private objA
Private Sub Class_Initialize()
Set objA = New A
End Sub

Public Property Get getA()
Set getA = objA
End Property

Public Property Let setA(pObjA)
Set objA = pObjA
End Property

End Class

dim objTest
Set objTest = new B
%>
luco 2003-03-04
  • 打赏
  • 举报
回复
Oh, you are great. I will test it later on. Hope that works. :D

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧