以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助][讨论]多个数组合并疑难  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=120791)

--  作者:sunion
--  发布时间:2018/6/23 22:36:00
--  [求助][讨论]多个数组合并疑难
有2个数组,怎么样用按钮代码实现新的数组呢?
想要的实现过程:数组1中的每一个字符尾部添加一个汉字——“队”,得到新的数组,然后再与数组1、数组2合并为需要的数组

已知数组如下:
Dim sj() As String = {"A","B","C","D"}     ‘数组1
Dim xm() As String = {"姓名","组别"}    ‘数组2

需要得到新数组实现的效果:
Dim new() As String ={"A","B","C","D","A队","B队","C队","D队","姓名","组别"}  
[此贴子已经被作者于2018/6/23 22:37:39编辑过]

--  作者:有点甜
--  发布时间:2018/6/24 22:38:00
--  

Dim sj() As String = {"A","B","C","D"}     \'数组1
Dim xm() As String = {"姓名","组别"}    \'数组2
Dim all(sj.length-1+sj.length-1+xm.length-1) As String
For i As Integer = 0 To sj.length-1
    all(i*2) = sj(i)
    all(i*2+1) = sj(i) & "队"
Next
Dim idx = (sj.length-1)*2
For i As Integer = 0 To xm.length-1
    all(idx+i) = xm(i)
Next

msgbox(string.join(",", all))