以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  请求大师指教!谢谢!  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=96954)

--  作者:jackyfashion
--  发布时间:2017/3/2 23:29:00
--  请求大师指教!谢谢!
我有nydc1至nydc18共18列,当我选中某列左边列自动以选定列+ivud列,
Dim t As Table = CurrentTable
t.ApplySort = False
Dim d As Col = t.Cols(t.ColSel) \' 这选定列的名称是"ntdc3
Dim z() As String = d.name.split("c")
For Each r As Row In t.rows
    Dim b1 = z(1) + 1
    Dim f1 = z(0) & "c" & b1
    r(f1) = (r(d) + r("siud"))
Next
For Each r As Row In t.rows
    Dim b2 = z(1) + 2
    Dim f2 = z(0) & "c" & b2
    r(f2) = (r(d) + (r("siud") * 2))
Next
For Each r As Row In t.rows
Dim b3 = z(1) + 3
Dim f3 = z(0) & "c" & b3
    r(f3) = (r(d) + (r("siud") * 3))
Next
For Each r As Row In t.rows
Dim b4 = z(1) + 4
Dim f4 = z(0) & "c" & b4
    r(f4) = (r(d) + (r("siud") * 4))
Next
For Each r As Row In t.rows
Dim b5 = z(1) + 5
Dim f5 = z(0) & "c" & b5
    r(f5) = (r(d) + (r("siud") * 5))
Next
For Each r As Row In t.rows
Dim b6 = z(1) + 6
Dim f6 = z(0) & "c" & b6
    r(f6) = (r(d) + (r("siud") * 6))
Next
For Each r As Row In t.rows
Dim b7 = z(1) + 7
Dim f7 = z(0) & "c" & b7
    r(f7) = (r(d) + (r("siud") * 7))
Next
For Each r As Row In t.rows
Dim b8 = z(1) + 8
Dim f8 = z(0) & "c" & b8
    r(f8) = (r(d) + (r("siud") * 8))
Next
For Each r As Row In t.rows
Dim b9 = z(1) + 9
Dim f9 = z(0) & "c" & b9
    r(f9) = (r(d) + (r("siud") * 9))
Next
For Each r As Row In t.rows
Dim b10 = z(1) + 10
Dim f10 = z(0) & "c" & b10
    r(f10) = (r(d) + (r("siud") * 10))
Next
For Each r As Row In t.rows
Dim b11 = z(1) + 11
Dim f11 = z(0) & "c" & b11
    r(f11) = (r(d) + (r("siud") * 11))
Next
For Each r As Row In t.rows
Dim b12 = z(1) + 12
Dim f12 = z(0) & "c" & b12
    r(f12) = (r(d) + (r("siud") * 12))
Next
For Each r As Row In t.rows
Dim b13 = z(1) + 13
Dim f13 = z(0) & "c" & b13
    r(f13) = (r(d) + (r("siud") * 13))
Next
For Each r As Row In t.rows
Dim b14 = z(1) + 14
Dim f14 = z(0) & "c" & b14
    r(f14) = (r(d) + (r("siud") * 14))
Next
For Each r As Row In t.rows
Dim b15 = z(1) + 15
Dim f15 = z(0) & "c" & b15
    r(f15) = (r(d) + (r("siud") * 15))
Next
For Each r As Row In t.rows
Dim b16 = z(1) + 16
Dim f16 = z(0) & "c" & b16
    r(f16) = (r(d) + (r("siud") * 16))
Next
For Each r As Row In t.rows
Dim b17 = z(1) + 17
Dim f17 = z(0) & "c" & b17
    r(f17) = (r(d) + (r("siud") * 17))
Next
当我选定nydc5,那计算的列就是nydc22,系统提示nydc19不是CurrentTable的列,请各位大师指教,点写代码?谢谢!!!谢谢!!!



--  作者:有点色
--  发布时间:2017/3/3 1:25:00
--  

 你这段代码需要优化。

 

 单独做一个表,上传上来,举例说明怎么操作,最后要什么效果。


--  作者:jackyfashion
--  发布时间:2017/3/3 21:05:00
--  
多谢大师的帮助和指教! 上传不了文件,不知是什么原因。

谢谢!!!

--  作者:有点蓝
--  发布时间:2017/3/3 21:50:00
--  
上传文件参考:http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=78
--  作者:jackyfashion
--  发布时间:2017/3/3 23:45:00
--  

谢谢大师帮助及指教!!!


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

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目1.foxdb


--  作者:有点蓝
--  发布时间:2017/3/4 9:21:00
--  
Dim t As Table = CurrentTable
t.StopRedraw
t.ApplySort = False
Dim d As Col = t.Cols(t.ColSel) \' 这选定列的名称是"ntdc3
Dim idx As Integer = CInt(d.Name.Replace("nydc",""))
For Each dr As DataRow In t.DataTable.DataRows
    Dim v1 As Double = dr(d.Name)
    Dim v2 As Double = dr("siud")
    Dim j As Integer = 1
    For i As Integer = idx+1 To 18
        dr("nydc" & i) = v1 + j * v2
        j += 1
    Next
    j = 1
    For i As Integer = idx-1 To 1 Step -1
        dr("nydc" & i) = v1 - j * v2
        j += 1
    Next
Next
t.ResumeRedraw

--  作者:jackyfashion
--  发布时间:2017/3/5 0:33:00
--  
谢谢大师帮忙及指教!!!
--  作者:jackyfashion
--  发布时间:2017/3/9 22:19:00
--  
请教大师:我nydc1至18,这18个列,如果隐藏,就不计算,请教需改那个代码?谢谢!!!
--  作者:有点色
--  发布时间:2017/3/10 1:46:00
--  
Dim t As Table = CurrentTable
t.StopRedraw
t.ApplySort = False
Dim d As Col = t.Cols(t.ColSel) \' 这选定列的名称是"ntdc3
Dim idx As Integer = CInt(d.Name.Replace("nydc",""))
For Each dr As DataRow In t.DataTable.DataRows
    Dim v1 As Double = dr(d.Name)
    Dim v2 As Double = dr("siud")
    Dim j As Integer = 1
    For i As Integer = idx+1 To 18
        If t.cols("nydc" & i).Visible Then
            dr("nydc" & i) = v1 + j * v2
            j += 1
        End If
    Next
    j = 1
    For i As Integer = idx-1 To 1 Step -1
        If t.cols("nydc" & i).Visible Then
            dr("nydc" & i) = v1 - j * v2
            j += 1
        End If
    Next
Next
t.ResumeRedraw

--  作者:jackyfashion
--  发布时间:2017/3/10 20:01:00
--  
谢谢大师