如下代码,求高手优化
Dim Cn() As String = {"代码","全名","规格型号","名称"}
Dim tb As Table = Tables("物料表")
Dim tbdb As Table = Tables("物料导入_Tab物料对比")
Dim tbdr As Table = Tables("物料导入_Tab物料导入")
Dim i As Integer
Dim ii As Integer
'Dim ci As Integer
Dim vstr As String
Dim vi As Integer
Dim tbstr As String
Dim drstr As String
DataTables("物料对比").StopRedraw
For i = 0 To tbdr.Rows.Count - 1
drstr = tbdr.Rows(i)("代码")
For ii = 0 To tb.Rows.Count -1
tbstr = tb.Rows(ii)("代码")
If tbstr = drstr Then
vi = 0
For ci As Integer = 0 To cn.Length -1
If tbdr.Rows(i)(cn(ci)) <> tb.Rows(ii)(cn(ci)) Then
vi = vi +1
vstr = vstr & "|" & cn(ci)'tbdr.Rows(i)(cn(ci))
End If
Next
Exit For
Else
vi = 1001
vstr = Nothing
End If
Next
If vi > 0 Then
Dim r As Row = tbdb.AddNew
For ci As Integer = 0 To cn.Length -1
r(cn(ci)) = tbdr.Rows(i)(cn(ci))
Next
If vi = 1001 Then
r("异类") = "新增"
Else
r("异类") = "修改"
End If
r("原因") = vstr
End If
'i = 0
Next
DataTables("物料对比").ResumeRedraw
tbdb.AutoSizeCols
MessageBox.Show("全部对比完成","完成",MessageBoxButtons.OK,MessageBoxicon.Information)