dim list as new Collection,i as interger for i=0 to 6000 list.add(i) next当list的count到达256时就不能再添加了,list最大长度就是256?vb6中还有什么集合类似于collection,可以使用add和remove方法的,如果自己定义一个类,实现remove方法,remove的实现方法是不是删除一个元素,然后后面的元素前移?如果我的操作涉及到很频繁的移动,该怎么办?vb中能使用指针?
恩 呵呵,我的意思没有表达清楚。 我知道数组没有add和remove方法。 现在我写一个类,不用collection,实现和collection一样的功能。private container() as bytepublic property Get PContainer() as byte() PContainer=container end propertypublic sub Add(byref data() as byte) '增加的方法,这里增加的是数组 end sub public sub Remove(byval startIndex as integer,byval count as integer) '删除的方法,在删除方法中我需要从container数组中删除某些元素,所以我想这样做:假如删除从第一个元素开始到第10个元素, dim temp() as byte,i as integer redim temp(ubound(container)-count) for i=0 to ubound(container) if i>startindex and i<startindex+count then '说明这些数据应该删除 else '这些数据要保留 end if next end sub我的意思像上面代码中那样,如果现在我写了这么一个类,删除的时候用到了类似于数组的复制,这样会不会太慢?有没有更好的方法?类似于数据结构中单链表那样的用指针来实现?
描述对象,用于存储数据关键字和条目对。语法Scripting.Dictionary说明Dictionary 对象与 PERL 关联数组等价。可以是任何形式的数据的条目被存储在数组中。每个条目都与一个唯一的关键字相关联。该关键字用来检索单个条目,通常是整数或字符串,可以是除数组外的任何类型。下面的代码举例说明了如何创建一个 Dictionary 对象:Dim d '创建一个变量
Set d = CreateObject(Scripting.Dictionary)
d.Add "a", "Athens" '添加一些关键字和条目
d.Add "b", "Belgrade"
d.Add "c", "Cairo"
...
如果自己定义一个类,实现remove方法,remove的实现方法是不是删除一个元素,然后后面的元素前移?如果我的操作涉及到很频繁的移动,该怎么办?vb中能使用指针?
dim dic as object
set dic = createobject("scripting.dictionary")
同样也可以add和remove方法,不过用法稍有不同。
参考:
http://download.csdn.net/source/1679235
依次展开:Windows 脚本技术 -> 脚本运行时库 -> Dictionary 对象
恩 有道理
我说数组那个是想用数组作为存储的介质,然后实现remove方法。想寻求remove方法的方法。
list没有长度限制,不过如果添加监视窗口的话他就显示256个,其余的都不是显示了。但是确是存在的。。谢谢
监视窗口和立即窗口能显示的字符数量比较有限.
恩
呵呵,我的意思没有表达清楚。
我知道数组没有add和remove方法。
现在我写一个类,不用collection,实现和collection一样的功能。private container() as bytepublic property Get PContainer() as byte()
PContainer=container
end propertypublic sub Add(byref data() as byte)
'增加的方法,这里增加的是数组
end sub
public sub Remove(byval startIndex as integer,byval count as integer)
'删除的方法,在删除方法中我需要从container数组中删除某些元素,所以我想这样做:假如删除从第一个元素开始到第10个元素,
dim temp() as byte,i as integer
redim temp(ubound(container)-count)
for i=0 to ubound(container)
if i>startindex and i<startindex+count then
'说明这些数据应该删除
else
'这些数据要保留
end if
next
end sub我的意思像上面代码中那样,如果现在我写了这么一个类,删除的时候用到了类似于数组的复制,这样会不会太慢?有没有更好的方法?类似于数据结构中单链表那样的用指针来实现?