以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]自定义函数中定义参数问题(已解决)  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=77645)

--  作者:苦为用功
--  发布时间:2015/11/23 10:19:00
--  [求助]自定义函数中定义参数问题(已解决)

原来是在动态表达式一章图片点击可在新窗口打开查看


初学自定义函数,以下代码在表中有对应的编号和类别列的话可以使用,如果列名称不相同的话,就不能使用了。不知道怎么把下列代码按参数修改,还请指教。

max = e.DataTable.Compute("Max(编号)","类别 = \'" & lb & "\' And [_Identify] <> " & e.DataRow("_Identify")) \'取得该类别的最大

                ——以上代码中 编号 和类别怎么修改?——


Dim e As object = args(0)
Dim lbs As String = args(1) \'类别列
Dim bhs As String = args(2) \'编号列

Select e.DataCol.Name
    Case lbs

       
If e.DataRow.IsNull(lbs) Then
            e.
DataRow(bhs) = Nothing
        Else
            Dim
lb As String = e.DataRow(lbs)
            If
e.DataRow(bhs).StartsWith(lb) = False \'如果单据编号前缀不符
               
Dim max As String
               
Dim idx As Integer

                max = e.DataTable.Compute("Max(编号)","类别 = \'" & lb & "\' And [_Identify] <> " & e.DataRow("_Identify")) \'取得该类别的最大

                ——以上代码中 编号 和类别怎么使用?——
               
If max > "" Then \'如果存在最大编号
                    idx = CInt(max.Substring(
2,3)) + 1 \'获得最大编号的后三位顺序号,并加1
               
Else
                    idx =
1 \'否则顺序号等于1
               
End If
                e.
DataRow(bhs) = lb & Format(idx,"000")
            End
If
        End
If
End
Select

[此贴子已经被作者于2015/11/23 10:41:38编辑过]

--  作者:大红袍
--  发布时间:2015/11/23 10:21:00
--  
 max = e.DataTable.Compute("Max(" & bhs & ")","类别 = \'" & lb & "\' And [_Identify] <> " & e.DataRow("_Identify")) \'取得该类别的最大编号
--  作者:苦为用功
--  发布时间:2015/11/23 10:37:00
--  
谢谢大红袍老师!