以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  自动复制行的时候,数据列可否变成负数?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=18330)

--  作者:yacity
--  发布时间:2012/4/9 17:45:00
--  自动复制行的时候,数据列可否变成负数?

教程地址

http://www.foxtable.com/help/topics/2292.htm

 

其中

 

……

 

如果列名不同,或者只需复制部分列,可以参考下面的代码:

If e.DataCol.Name = "逻辑列名" AndAlso e.DataRow("逻辑列名") = True Then
    Dim nma() As String = {"A1","A2","A3","A4"}
\'A表数据来源列
    Dim nmb() As String = {"B1"
,"B2","B3","B4"} \'B表数据接收列
    Dim dr As DataRow = DataTables("表B"
).AddNew
   
For i As Integer = 0 To nma.Length - 1
        dr(nmb(i)) = e.DataRow(nma(i))
   
Next
End
If

 

 

 

 

如果我有一列数据列 比如 “数量”

Dim nma() As String = {"A1","A2","A3","A4","数量"}

复制到新的表的时候 我想让他变成负数。怎么弄呢?

 

[此贴子已经被作者于2012-4-9 17:45:21编辑过]

--  作者:狐狸爸爸
--  发布时间:2012/4/9 18:01:00
--  
If e.DataCol.Name = "逻辑列名" AndAlso e.DataRow("逻辑列名") = True Then
    Dim nma() As String = {"A1","A2","A3","A4","数量"} \'A表数据来源列
    Dim nmb() As String = {"B1","B2","B3","B4","数量"} \'B表数据接收列
    Dim dr As DataRow = DataTables("表B").AddNew
    For i As Integer = 0 To nma.Length - 1
        dr(nmb(i)) = e.DataRow(nma(i))
    Next
    dr("数量") = -dr("数量")
End If