以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 如何编写两个表之间计算近似值的代码 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=46796) |
-- 作者:yyyyyy -- 发布时间:2014/2/27 18:05:00 -- 如何编写两个表之间计算近似值的代码
有两个表:表1、表3,
求:表3“当年位次”列中的数据,与表1“预测位次”列中的数据最接近的值,
显示在表1的“最接近位次”列中,
如何编写代码、公式? 谢谢啦。
|
-- 作者:有点甜 -- 发布时间:2014/2/27 20:58:00 -- 要编写datacolchanged事件.代码类似 If e.DataCol.name = "预测位次" Then Dim ldr As DataRow = DataTables("表3").find("当年位次 <= \'" & e.DataRow("预测位次") & "\'", "当年位次 desc") Dim mdr As DataRow = DataTables("表3").find("当年位次 >= \'" & e.DataRow("预测位次") & "\'", "当年位次") If e.DataRow("预测位次") - ldr("当年位次") <= mdr("当年位次") - e.DataRow("预测位次") Then e.DataRow("最接近位次") = ldr("当年位次") e.DataRow("预测分数") = ldr("当年分数") Else e.DataRow("最接近位次") = mdr("当年位次") e.DataRow("预测分数") = mdr("当年分数") End If End If
|