最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
VBSctipt 5.0中的新特性
时间:2022-06-30 09:41:17 编辑:袖梨 来源:一聚教程网
VBSctipt 5.0中的新特性
能够在ASP中应用的特性包括了那些由脚本引擎所提供的特性,这意味着VBScript的改进也可在ASP中应用。VBScript的改进如下所述:
1、 在脚本中使用类
在VBScript中实现完整的VB类(class)模型,但明显的例外是在ASP服务器端的脚本事件。可以在脚本中创建类,使它们的属性和方法能够和用于页面的其余代码,例如:
Class MyClass
Private m_HalfValue 'Local variable to hold value of HalfValue
Public Property Let HalfValue(vData) 'executed to set the HalfValue property
If vData > 0 Then m_HalfValue = vData
End Property
Public Property Get HalfValue() 'executed to return the HalfValue property
HalfValue = m_HalfValue
End Property
Public Function GetResult() 'implements the GetResult method
GetResult = m_HalfVaue * 2
End Function
End Class
Set ObjThis = New MyClass
ObjThis.HalfValue = 21
Response.Write “Value of HalfValue property is “ & objThis.HalfValue & “
”
Response.Write “Result of GetResult method is “ & objThis.GetResult & “
”
…
这段代码产生如下结果:
Value of HalfValue property is 21
Result of GetResult method is 42
2、 With结构
VBScript 5.0支持With结构,使访问一个对象的几个属性或方法的代码更加紧凑:
…
Set objThis = Server.CreateObject(“This.object”)
With objThis
.Property1 = “This value”
相关文章
- 《弓箭传说2》新手玩法介绍 01-16
- 《地下城与勇士:起源》断桥烟雨多买多送活动内容一览 01-16
- 《差不多高手》醉拳龙技能特点分享 01-16
- 《鬼谷八荒》毕方尾羽解除限制道具推荐 01-16
- 《地下城与勇士:起源》阿拉德首次迎新春活动内容一览 01-16
- 《差不多高手》情圣技能特点分享 01-16