请问要增加的辅助序号列是不是直接增加个列,然后未筛选排序前每行1 2 3 4 5~这样排下去就行了?
另外您帮添加的代码,我这样接是对的吗?就是把原先代码end if后面的替换下
Dim t As Table = Tables("表A")
Dim x = 200
Dim y = 200
Dim c = 5
Dim drs = t.DataTable.Select("")
Dim ary1(drs.count-1) As Integer
Dim ary3(drs.count-1) As Double
For i As Integer = 0 To drs.count-1
Dim dr As DataRow = drs(i)
ary1(i) = dr("_Identify")
Dim s = dr("第一列")
s = s.replace("(", "").replace(")", "")
Dim ary = s.split(",")
If ary.length = 2 Then
ary3(i) = Math.Sqrt((x-ary(0))^2+(y-ary(1))^2)
Else
ary3(i) = Math.Sqrt((x)^2+(y)^2)
End If
Next
Dim dict As new Dictionary(of Integer,Integer)
array.sort(ary3, ary1)
Dim str As String = ""
For i As Integer = 1 To c
dict.Add(ary1(i-1),i)
str &= ary1(i-1) & ","
Next
t.filter = "_Identify in (" & str.trim(",") & ")"
For Each r As Row In t.Rows
r("序号") = dict(r("_Identify"))
Next
t.sort = "序号"