以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  求 一段代码  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=72137)

--  作者:feifei998
--  发布时间:2015/7/23 23:10:00
--  求 一段代码
 Dim Names As String() = {"文本","文本","日期","文本","日期"}
Dim aa As String
For Each Name As String In Names
    If name = "文本" Then
      
       End If
Next

我想遍历Names 数组

如果出现 一次文本 数值为D1。。。。Dn用逗号隔开
如果出现  一次日期  数值为T1.。。。Tn
结果为 (D1,D2,T1,D3,T2)这个样子
      

--  作者:don
--  发布时间:2015/7/24 0:32:00
--  
Dim Names As String() = {"文本","文本","日期","文本","日期","文本","文本","日期","文本","日期","文本","文本","日期","文本","日期","文本","文本","日期","文本","日期"}
Dim aa ,s1,s2 As String
For Each Name As String In Names
    s1+=Name
    s2=s1
    Dim i As Integer= (s2.Length-s2.Replace(name,"").Length)/Name.Length
    If name = "文本" Then
        aa+=",D"  & i
    Else
        aa+=",T"    &  i
    End If
Next

Output.Show(aa.trim(","))