当前位置: 首页 > 图文教程 > 脚本技术 > VBScript > VBS ArrayList Class vbs中的数组类

VBScript
Restart.vbs源代码可以重启远程电脑的vbs
远程或本地获取系统信息的脚本RGIS.vbs
远程开启/关闭目标telnet服务的windows脚本RTCS.vbs
可以得到当前系统信息的脚本sysinfo.vbs
RCMD使用说明
远程启动终端服务的windows脚本ROTS.vbs
解锁注册表的vbs脚本
如何使用脚本锁定任务栏?
灵活实用VBS入门教程应用篇
注册表-批处理-VBS之间的功能对应
收集的一些经典的vbs脚本大全
VBS+MSWinsock打造灵巧UDP后门的相关资料
一些经典的主要用户黑客的vbs脚本结合echo的dos下实现
可以定时自动关机的vbs脚本
利用wscript执行文件[包括可执行exe文件]vbs脚本
vbs实用软件自造——Windows脚本应用实例
防止网页脚本病毒执行的方法-from web
打开QQ并且让它自己输入用户名和密码的vbs脚本
多进程的实现投票的vbs脚本
用vbs脚本实现运行DOS批处理不再出现黑屏cmd窗口

VBScript 中的 VBS ArrayList Class vbs中的数组类


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-11   浏览: 121 ::
收藏到网摘: n/a

Class ArrayList
Private items()
Private size
Private Sub Class_Initialize
size = 0
ReDim items(1)
End Sub
Private Sub Class_Terminate
items = null
End Sub
Public Function Add(ByVal value)
If (size = Ubound(items)) Then EnsureCapacity((size + 1))
items(size) = value
size = size + 1
Add = size
End Function
Public Property Get Item(index)
Item = items(index)
End Property
Public Property Let Item(index, vObject)
items(index) = vObject
End Property
Property Get Count
Count = size
End Property

Public Property Get Capacity()
Capacity = Ubound(items)
End Property
Public Property Let Capacity(value)
If (value <> Ubound(items)) Then
If (value < size) Then Err.Rise 6
If (value > 0) Then
ReDim Preserve items(value)
Else
ReDim Preserve items(3)
End If
End If
End Property
Private Sub EnsureCapacity(ByVal min)
If (Ubound(items) < min) Then
Dim num1 : num1 = IIf((Ubound(items) = 0), 4, (Ubound(items) * 2))
If (num1 < min) Then num1 = min
Capacity = num1
End If
End Sub

Private Function IIf(j, r1, r2)
IF (j) Then
IIf = r1
Else
IIf = r2
End IF
End Function
End Class

示例:
Dim al : Set al = new ArrayList
al.Add(1)
al.Add(2)
al.Add(3)
al.Add(4)
al.Add(5)
al.Add(6)
al.Add(7)
al.Add(8)
al.Add(9)
al.Add(10)
For i = 0 To al.Count -1
w("Index"& i &": "& al.Item(i))
Next
w("Count: "& al.Count)
w("Capacity: "& al.Capacity)
Sub w(o)
Response.Write(o &"<br />")
End Sub