最新下载
热门教程
- 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”
相关文章
- 《暖雪》慈母教圣文获取方式有哪些 06-16
- 《星球重启》伊甸城两连湾有哪些 06-16
- 《问剑长生》修士第一境界如何 06-16
- 《星球重启》进不去怎么解决 06-16
- 《异环》主要角色大全 06-16
- 《空之要塞:启航》赫山背景故事怎样 06-16