Foxtable(狐表)用户栏目专家坐堂 → [求助]遍历整列,计算每行数字与最近的相同数字间的距离


  共有2961人关注过本帖树形打印复制链接

主题:[求助]遍历整列,计算每行数字与最近的相同数字间的距离

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/9/15 15:15:00 [显示全部帖子]

Dim t As Table = Tables("表a")
For i As Integer = 0 To t.rows.count-1
    For j As Integer = i+1 To t.rows.count-1
        If t.rows(i)("第一列") = t.rows(j)("第一列") Then
            t.rows(i)("第二列") = j-i
        End If
    Next
Next

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/9/19 15:40:00 [显示全部帖子]

Dim t As Table = Tables("表a")

For i As Integer = 0 To t.rows.count-1
    Dim down As Integer = 0
    Dim up As Integer = 0
    For j As Integer = i+1 To t.rows.count-1
        If t.rows(i)("第一列") = t.rows(j)("第一列") Then
            down = j-i-1
            Exit For
        End If
    Next
    For j As Integer = i-1 To 0 Step -1
        If t.rows(i)("第一列") = t.rows(j)("第一列") Then
            up = i-j-1
            Exit For
        End If
    Next
    t.rows(i)("第二列") = iif(down>up, down, iif(up=0, Nothing, up))
Next


 回到顶部