呃,不明白你的意思,红色代码如果不需要,可以删掉。请上传具体的例子说明你的问题。
For Each n As String In DataTables("表A").GetValues("第一列", "第一列 is not null")
Dim dr1 As DataRow = DataTables("表A").Find("第一列 = '" & n & "'", "第二列")
Dim dr2 As DataRow = DataTables("表A").Find("第一列 = '" & n & "'", "第二列 desc")
Dim fdr As DataRow = DataTables("表D").Find("第一列 = '" & n & "'")
If fdr Is Nothing Then
fdr = DataTables("表D").AddNew
fdr("第一列") = n
End If
Dim x1 As Double = dr1("第五列")
Dim y1 As Double = dr1("第六列")
Dim x2 As Double = dr2("第五列")
Dim y2 As Double = dr2("第六列")
Dim rad As Double = 6371
Dim p1X As Double = X1 / 180 * Math.PI
Dim p1Y As Double = Y2 / 180 * Math.PI
Dim p2X As Double = X2 / 180 * Math.PI
Dim p2Y As Double = Y2 / 180 * Math.PI
Dim result As Double = Math.Acos(Math.Sin(p1Y) * Math.Sin(p2Y) + Math.Cos(p1Y) * Math.Cos(p2Y) * Math.Cos(p2X - p1X)) * rad
fdr("第二列") = result
Next