以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]如何根据线路,拆分路段 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=154451) |
-- 作者:wflqf -- 发布时间:2020/9/15 14:46:00 -- [求助]如何根据线路,拆分路段 线路:北京-淮安-江阴-上海,拆分为路段:北京-淮安,淮安-江阴,江阴-上海 用以下代码: Dim dt1 As DataTable = DataTables("表A") Dim dt2 As DataTable = DataTables("表B") For Each dr As DataRow In dt1.Select("") Dim ls1 As new List(Of String) ls1.AddRange(dr("线路").split("-")) For i As Integer = 1 To ls1.count -1 Dim ndr As DataRow = dt2.AddNew ndr("日期") = dr("日期") ndr("线路") = dr("线路") ndr("路段") = ls1(0) & "-" & ls1(i) Next Next 拆分后路段:北京-淮安,北京-江阴,北京-上海,如何修改此代码,拆分路段为:北京-淮安,淮安-江阴,江阴-上海
|
-- 作者:有点蓝 -- 发布时间:2020/9/15 15:05:00 -- Dim s As String = "北京-淮安-江阴-上海" Dim arr() As String = s.Split("-") For i As Integer = 1 To arr.Length - 1 Output.Show(arr(i-1) & "-" & arr(i)) Next |
-- 作者:wflqf -- 发布时间:2020/9/15 15:14:00 -- 我这脑袋来,直接晕了,这么简单的问题,居然,,, |