VBS ArrayList Class vbs中的数组类_vbs教程-查字典教程网
VBS ArrayList Class vbs中的数组类
VBS ArrayList Class vbs中的数组类
发布时间:2016-12-28 来源:查字典编辑
摘要:ClassArrayListPrivateitems()PrivatesizePrivateSubClass_Initializesize=...

ClassArrayList

Privateitems()

Privatesize

PrivateSubClass_Initialize

size=0

ReDimitems(1)

EndSub

PrivateSubClass_Terminate

items=null

EndSub

PublicFunctionAdd(ByValvalue)

If(size=Ubound(items))ThenEnsureCapacity((size+1))

items(size)=value

size=size+1

Add=size

EndFunction

PublicPropertyGetItem(index)

Item=items(index)

EndProperty

PublicPropertyLetItem(index,vObject)

items(index)=vObject

EndProperty

PropertyGetCount

Count=size

EndProperty

PublicPropertyGetCapacity()

Capacity=Ubound(items)

EndProperty

PublicPropertyLetCapacity(value)

If(value<>Ubound(items))Then

If(value<size)ThenErr.Rise6

If(value>0)Then

ReDimPreserveitems(value)

Else

ReDimPreserveitems(3)

EndIf

EndIf

EndProperty

PrivateSubEnsureCapacity(ByValmin)

If(Ubound(items)<min)Then

Dimnum1:num1=IIf((Ubound(items)=0),4,(Ubound(items)*2))

If(num1<min)Thennum1=min

Capacity=num1

EndIf

EndSub

PrivateFunctionIIf(j,r1,r2)

IF(j)Then

IIf=r1

Else

IIf=r2

EndIF

EndFunction

EndClass

示例:

Dimal:Setal=newArrayList

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)

Fori=0Toal.Count-1

w("Index"&i&":"&al.Item(i))

Next

w("Count:"&al.Count)

w("Capacity:"&al.Capacity)

Subw(o)

Response.Write(o&"<br/>")

EndSub

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新vbs学习
    热门vbs学习
    脚本专栏子分类