我这样测试没问题,请测试弹出的值分别是什么。
Dim _username, _lxs
msgbox(ClipBoard.GetText)
Dim rs As String()=ClipBoard.GetText.Replace(chr(10),"").split(chr(13))
If rs(0).Contains("******************") = False Then '先简单判断一下格式是否正确
msgbox("不可识别的格式!")
Return Nothing
End If
Dim xg As Integer = rs(3).LastIndexOf("/") '找出/的位置
Dim gngj As String = "" '定义gngj来记录国内国际
msgbox(xg)
If xg >= 0 Then
If rs(3).SubString(xg-1,1) = "1" Then
gngj = "国际"
Else
If rs(3).SubString(xg-1,1) = "2" Then
gngj = "国内"
End If
End If
End If
Dim starts,Ends As new List(of Integer) '定义集合 来记录有效数据的开始行和结束行
For i As Integer = 0 To rs.Length -1
If rs(i).Contains("TKT-NUMBER") Then
starts.Add(i+2) '已经是真实行值了
End If
If rs(i).Contains("TOTAL TICKETS") Then
ends.Add(i-2) '已经是真实行值了
End If
Next
msgbox(starts.count)
msgbox(Ends.count)
For x As Integer = 0 To Ends.Count - 1 '遍历每一大组有效数据
For ii As Integer = starts(x) To Ends(x)
Dim datas() As String = rs(ii).trim().Replace(" "," ").Replace(" "," ").Replace(" "," ").Split(" ") '这已经是提取到了每一个具体行了,并做好了分割
Dim ddr As DataRow = DataTables("机piao").SQLFind("piao号 = '" & datas(0).Replace("-","") & "'")
If ddr Is Nothing Then '若 没有piao号重复值
If rs(ii).Contains("VOID") = True Then '若包含了viod 要特殊处理
Dim dr As DataRow = DataTables("机piao").AddNew '先新增一行
dr("出piao人") = _username
dr("旅行社") = _lxs
dr("添加日期") = Date.Today
dr("十位piao号") = datas(0).SubString(4)
dr("piao号") = datas(0).Replace("-","")
dr("航班号") = "VOID"
dr("国内国际") = gngj
dr("数据来源") = "BSP"
Else
If rs(ii).Contains("REFUND") = True Then '若包含了ET-REFUND 要特殊处理
Dim dr As DataRow = DataTables("机piao").AddNew '先新增一行
dr("添加日期") = Date.Today
dr("出piao人") = _username
dr("旅行社") = _lxs
dr("十位piao号") = datas(0).SubString(4)
dr("piao号") = datas(0).Replace("-","")
dr("航班号") = "REFUND"
dr("国内国际") = gngj
dr("数据来源") = "BSP"
Else
Dim dr As DataRow = DataTables("机piao").AddNew '先新增一行
dr("添加日期") = Date.Today
dr("出piao人") = _username
dr("旅行社") = _lxs
dr("十位piao号") = datas(0).SubString(4)
dr("piao号") = datas(0).Replace("-","")
dr("行程") = datas(1) & datas(2)
dr("piao款") = datas(3)
dr("导入税款") = datas(4)
dr("PNR") = datas(6)
dr("出piao人") = datas(7)
dr("国内国际") = gngj
dr("数据来源") = "BSP"
End If
End If
End If
Next
Next