以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  将一表内相同姓名的同学用期中减月一  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=127596)

--  作者:dzy1232016
--  发布时间:2018/11/17 17:05:00
--  将一表内相同姓名的同学用期中减月一
将一表内相同姓名的同学用期中减月一
相当于每两行数据之间又要增加一行(作差的结果)
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目1.table

[此贴子已经被作者于2018/11/17 17:05:13编辑过]

--  作者:有点蓝
--  发布时间:2018/11/17 17:20:00
--  
参考:

Dim r As Row
Dim t As Table = Tables("data")
For i As Integer = t.Rows.Count - 1 To 2 Step -2
    Dim r1 As Row = t.Rows(i-1)
    t.Position = i+1
    Dim r2 As Row = t.Rows(i)
    r= t.InsertNew
    r("姓名") = r2("姓名")
    For Each c As Col In t.Cols
        If c.IsNumeric Then
            r(c.Name) = r2(c.Name) - r1(c.Name)
        End If
    Next
Next
[此贴子已经被作者于2018/11/17 17:20:35编辑过]

--  作者:dzy1232016
--  发布时间:2018/11/17 17:44:00
--  
提示此表不支持行插入功能
--  作者:y2287958
--  发布时间:2018/11/17 23:16:00
--  
要设置列标志
--  作者:y2287958
--  发布时间:2018/11/18 0:49:00
--  
Dim ss As List(of String) = DataTables("data").GetValues("学号")
Dim lst As new List(of String)
For Each s As String In ss
    Dim dr1 As DataRow = DataTables("data").Find("学号=\'" & s & "\'","考次 desc")
    Dim dr2 As DataRow = DataTables("data").Find("学号=\'" & s & "\'","考次 desc",1)
    Dim ds As String = dr1("班级") & "," & dr1("学号") & "," & dr1("姓名") & ",比较"
    For Each dc As DataCol In DataTables("data").DataCols
        If dc.Name<>"班级" AndAlso dc.Name<>"学号" AndAlso dc.Name<>"姓名" AndAlso dc.Name<>"考次"
            If dr1 IsNot Nothing AndAlso dr2 IsNot Nothing
                ds += "," & (dr2(dc.Name) - dr1(dc.Name))
            Else
                ds += "," & dr1(dc.Name)
            End If
        End If
    Next
    lst.Add(ds)
Next
For Each ls As String In lst
    Dim dr As DataRow = DataTables("data").AddNew
    For i As Integer = 0 To DataTables("data").DataCols.Count-1
        dr(Tables("data").Cols(i).Name) = ls.Split(",")(i)
    Next
Next
Tables("data").sort = "班级,学号,姓名,考次 desc"

[此贴子已经被作者于2018/11/18 0:49:03编辑过]

--  作者:dzy1232016
--  发布时间:2018/11/18 15:33:00
--  
以下是引用y2287958在2018/11/18 0:49:00的发言:
Dim ss As List(of String) = DataTables("data").GetValues("学号")
Dim lst As new List(of String)
For Each s As String In ss
    Dim dr1 As DataRow = DataTables("data").Find("学号=\'" & s & "\'","考次 desc")
    Dim dr2 As DataRow = DataTables("data").Find("学号=\'" & s & "\'","考次 desc",1)
    Dim ds As String = dr1("班级") & "," & dr1("学号") & "," & dr1("姓名") & ",比较"
    For Each dc As DataCol In DataTables("data").DataCols
        If dc.Name<>"班级" AndAlso dc.Name<>"学号" AndAlso dc.Name<>"姓名" AndAlso dc.Name<>"考次"
            If dr1 IsNot Nothing AndAlso dr2 IsNot Nothing
                ds += "," & (dr2(dc.Name) - dr1(dc.Name))
            Else
                ds += "," & dr1(dc.Name)
            End If
        End If
    Next
    lst.Add(ds)
Next
For Each ls As String In lst
    Dim dr As DataRow = DataTables("data").AddNew
    For i As Integer = 0 To DataTables("data").DataCols.Count-1
        dr(Tables("data").Cols(i).Name) = ls.Split(",")(i)
    Next
Next
Tables("data").sort = "班级,学号,姓名,考次 desc"

谢谢正是我需要的[此贴子已经被作者于2018/11/18 0:49:03编辑过]