Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共5 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助]字符数组处理

1楼
kuroneko 发表于:2023/9/14 10:47:00
想将相同合同号对应的fphm用vbCrLf拼接提取出来,代码该怎么写呢

Dim hth As String 
Dim hths() As String = {"QAXSZ230811B/23088", "QAXSZ230811A/23079", "QAXSZ230811A/23079", "QAXSZ230328A/23039", "QAXSZ230328A/23039"}
Dim fphm As String 
Dim fphms() As String = {"666", "36357132", "36357333", "36356847", "36356864"}
Array.Sort(HTHs, fphms)

For j As Integer = 0 To HTHs.Length - 1
    Dim count As Integer = 0
    For k As Integer = j + 1 To HTHs.Length - 1
        If(hths(j) = hths(k)) Then
            count = count + 1
        Else
            fphm = fphm & "_" & fphms(j)
        End If
    Next
    If(count = 1) Then
        Output.Show("重复hth:" & HTHs(j))
        count = 0 '重置
    End If
Next 
2楼
y2287958 发表于:2023/9/14 10:50:00
想得到啥结果?
3楼
kuroneko 发表于:2023/9/14 10:54:00
想得到这种效果。数组hths中元素按fphms中元素对应排序,hths中元素重复时,将对应fphms中的元素进行拼接
QAXSZ230811B/23088:666
QAXSZ230811A/23079:36357132_36357333
QAXSZ230328A/23039: 36356847_36356864
[此贴子已经被作者于2023/9/14 10:57:16编辑过]
4楼
y2287958 发表于:2023/9/14 11:18:00
Dim hths() As String = {"QAXSZ230811B/23088", "QAXSZ230811A/23079", "QAXSZ230811A/23079", "QAXSZ230328A/23039", "QAXSZ230328A/23039"}
Dim fphms() As String = {"666", "36357132", "36357333", "36356847", "36356864"}
Dim dic As New Dictionary(Of String, list(Of String))
For i As Integer = 0 To hths.count - 1
    Dim lst As New List(Of String)
    If dic.ContainsKey(hths(i)) Then
        lst = dic(hths(i))
        lst.Add (fphms(i))
        dic(hths(i)) = lst
    Else
        lst.Add(fphms(i))
        dic.Add(hths(i), lst)
    End If 
Next 
For Each k As String In dic.Keys 
    Output.Show (k & ":" & String.Join ("_" , dic(K)))
Next 
5楼
kuroneko 发表于:2023/9/14 12:13:00
谢谢爸
共5 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02344 s, 2 queries.