以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  循环调用数据错位,怎么处理?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=121083)

--  作者:sunion
--  发布时间:2018/6/28 20:12:00
--  循环调用数据错位,怎么处理?
老师,你好,循环调用时,数据出现了错位,不知道代码哪里出了问题?是不是循环的原因?



图片点击可在新窗口打开查看此主题相关图片如下:qq图片20180628200853.png
图片点击可在新窗口打开查看

我想让统计的数据出现在同一行,需要的效果是:


图片点击可在新窗口打开查看此主题相关图片如下:qq图片20180628201100.png
图片点击可在新窗口打开查看




代码如下
Dim tp As Table = Tables("查询科目")
For ii As Integer = 0 To tp.Rows.Count -1
Dim t As Table = Tables("优秀学生")
t.StopRedraw
Dim r As Row
Dim max As Integer = Tables("班级成绩").Rows.Count - 1
If max > 13 Then max = 13
For i As Integer = 0 To max
    Tables("班级成绩").Sort = tp.Rows(ii)("学科") & " desc"
    r = t.AddNew
    r(tp.Rows(ii)("学科") & "_班排") = Tables("班级成绩").Rows(i)(tp.Rows(ii)("学科") & "班排")
    r(tp.Rows(ii)("学科") & "_排名") = Tables("班级成绩").Rows(i)(tp.Rows(ii)("学科") & "排名")
    r(tp.Rows(ii)("学科") & "_姓名") = Tables("班级成绩").Rows(i)("姓名")
    r(tp.Rows(ii)("学科") & "_分数") = Tables("班级成绩").Rows(i)(tp.Rows(ii)("学科"))
        
    Tables("班级成绩").Sort = "总分" & " desc"
    r("总分_班排") = Tables("班级成绩").Rows(i)("总分班排")
    r("总分_排名") = Tables("班级成绩").Rows(i)("总分排名")
    r("总分_姓名") = Tables("班级成绩").Rows(i)("姓名")
    r("总分_分数") = Tables("班级成绩").Rows(i)("总分")   
Next
t.ResumeRedraw
Next


--  作者:有点甜
--  发布时间:2018/6/28 21:42:00
--  
Dim tp As Table = Tables("查询科目")
Dim max As Integer = Tables("班级成绩").Rows.Count - 1
If max > 13 Then max = 13
Dim t As Table = Tables("优秀学生")
t.StopRedraw
t.addnew(max+1)
For ii As Integer = 0 To tp.Rows.Count -1    
    Dim r As Row        
    For i As Integer = 0 To max
        Tables("班级成绩").Sort = tp.Rows(ii)("学科") & " desc"
        r = t.rows(i)
        r(tp.Rows(ii)("学科") & "_班排") = Tables("班级成绩").Rows(i)(tp.Rows(ii)("学科") & "班排")
        r(tp.Rows(ii)("学科") & "_排名") = Tables("班级成绩").Rows(i)(tp.Rows(ii)("学科") & "排名")
        r(tp.Rows(ii)("学科") & "_姓名") = Tables("班级成绩").Rows(i)("姓名")
        r(tp.Rows(ii)("学科") & "_分数") = Tables("班级成绩").Rows(i)(tp.Rows(ii)("学科"))
       
        Tables("班级成绩").Sort = "总分" & " desc"
        r("总分_班排") = Tables("班级成绩").Rows(i)("总分班排")
        r("总分_排名") = Tables("班级成绩").Rows(i)("总分排名")
        r("总分_姓名") = Tables("班级成绩").Rows(i)("姓名")
        r("总分_分数") = Tables("班级成绩").Rows(i)("总分")
    Next
   
Next
t.ResumeRedraw