以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  关于自定义函数中的行  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=195665)

--  作者:pyh6918
--  发布时间:2025/2/26 18:45:00
--  关于自定义函数中的行
dim zzy as row = Tables("专业").Current
Dim zzh As Row = Tables("报告").AddNew
Functions.Execute("顺序","zzy","zzh")

顺序函数如下:
If  args(0)("批次") = "本科" Then
    args(1)("批次顺序")=200
ElseIf args(0)("批次") = "专科" Then
    args(1)("批次顺序")=400
Else
    args(1)("批次顺序")=1000
End If

错误所在事件:自定义函数顺序
详细错误信息:
调用的目标发生了异常。
从字符串“批次”到类型“Integer”的转换无效。
输入字符串的格式不正确。

请问怎么修改自定义函数?谢谢!!

--  作者:y2287958
--  发布时间:2025/2/27 8:05:00
--  
从字符串“批次”到类型“Integer”的转换无效

赋值与列类型不相符

--  作者:pyh6918
--  发布时间:2025/2/27 8:39:00
--  
怎么改才能相符?
--  作者:有点蓝
--  发布时间:2025/2/27 8:49:00
--  
批次列是什么列类型?

试试
dim zzy as row = Tables("专业").Current
if zzy isnot nothing
Dim zzh As Row = Tables("报告").AddNew
Functions.Execute("顺序","zzy","zzh")
endif
函数
dim zzy as row = args(0)
Dim zzh As Row = args(1)
If  zzy("批次") = "本科" Then
    zzh("批次顺序")=200
ElseIf zzy("批次") = "专科" Then
    zzh("批次顺序")=400
Else
    zzh("批次顺序")=1000
End If

--  作者:pyh6918
--  发布时间:2025/2/27 8:59:00
--  
批次列是字符型,批次顺序是整数型
按您的方法改后出现下面的错误提示:
无法将类型为“System.String”的对象强制转换为类型“Foxtable.Row”。

--  作者:有点蓝
--  发布时间:2025/2/27 9:07:00
--  
Functions.Execute("顺序",zzy,zzh)
--  作者:pyh6918
--  发布时间:2025/2/27 9:20:00
--  
多谢蓝版!可以了,原来是不用加引号图片点击可在新窗口打开查看