楼主,是因为在你的部品明细表里,没有对应的条码,查找不出对应的值,所以报错。
Dim t As Table = Tables("总表.子表") Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog dlg.Filter= "文本文件|*.txt" '设置筛选器 If dlg.ShowDialog = DialogResult.OK Then Dim strs As String = FileSys.ReadAllText(dlg.FileName) strs = strs.Replace(vblf, "") Dim rs() As String = strs.Split(vbcr) For i As Integer = 0 To rs.Length - 1 Dim cs() As String = rs(i).Split(",") If cs.Length = 4 Then Dim dr4 As Row = Tables("总表").Current Dim fdr As DataRow = t.DataTable.Find("条码 = '" & cs(1) & "' and 编号 = '" & dr4("编号") & "'") Dim dr3 As DataRow = DataTables("部品明细").Find("条码 = '" & cs(1) & "'") If dr3 IsNot Nothing Then If fdr Is Nothing Then Dim r As Row = t.Addnew() r("条码") = cs(1) r("品番") = dr3("品番") r("数量") = cs(2) * dr3("包装规格") Else fdr("数量") = fdr("数量") + cs(2) * dr3("包装规格") End If End If End If Next End If
|