以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  在集合中添加数组的问题,请前辈指点  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=49115)

--  作者:ntangjr
--  发布时间:2014/4/12 9:59:00
--  在集合中添加数组的问题,请前辈指点
Dim Arys As List(Of String())
Dim Ary(2) As String

ary(0) = "A"
ary(1) = "B"
Arys.Add(ary)

For Each ary In arys
    output.show(ary(0))
Next

--  作者:Bin
--  发布时间:2014/4/12 10:01:00
--  
Dim Arys As new List(Of String())
Dim Ary(2) As String

ary(0) = "A"
ary(1) = "B"
Arys.Add(ary)

For Each ary In arys
    output.show(ary(0))
Next

--  作者:ntangjr
--  发布时间:2014/4/12 10:45:00
--  

非常感谢Bin的回复,我还有一个新问题,请指教,下面的代码,为何Messagebox 两次的显示值都是 B,应该第一次 A,第二次 B 啊?


Dim Arys As New List(Of String())
Dim Ary(2) As String
Dim strLength As Integer = 2
ary(0) = "A"
ary(1) = "A"
Arys.Add(ary)
ary(0) = "B"
ary(1) = "B"
Arys.Add(ary)

For Each ary In arys
    Messagebox.show(ary(0))
Next

--  作者:Bin
--  发布时间:2014/4/12 10:48:00
--  
呵呵,这里就要说到编程底层的东西了. 解析可能只会让你迷茫.

Dim Arys As New List(Of String())
Dim Ary(2) As String
Dim Ary2(2) As String
Dim strLength As Integer = 2
ary(0) = "A"
ary(1) = "A"
Arys.Add(ary)
ary2(0) = "B"
ary2(1) = "B"
Arys.Add(ary2)

For Each ary In arys
    Messagebox.show(ary(0))
Next

改为这样即可.

--  作者:ntangjr
--  发布时间:2014/4/12 10:59:00
--  
这段代码是我为了求助简化过的,我的目标是将选中的树节点,包括其父节点,父节点的父节点.... .... 放入一个集合,
要用到循环的,如何解决?请指教 

Dim Arys As New List(Of String())
Dim Ary(2) As String

ary(0) = "A"
ary(1) = "A"
Arys.Insert(0,ary)
ary(0) = "B"
ary(1) = "B"
Arys.Add(ary)

For Each ary In arys
    Messagebox.show(ary(0))
Next

--  作者:Bin
--  发布时间:2014/4/12 11:02:00
--  
你直接说出你的需求,上例子.
--  作者:ntangjr
--  发布时间:2014/4/12 11:18:00
--  
问题已经解决。

Dim Arys As New List(Of String)
Dim ary() As String
Dim str As String

str = "A" & "|" & "B"
Arys.Insert(0,str)
str = "C" & "|" & "D"
Arys.Add(str)

For Each str In arys
    ary = str.Split("|")
    Messagebox.show(ary(0))
Next