写Eval公式『六步曲』
左拼部分 + 用Substitute把分隔符替换部分(中间) + 右凑部分
1、 写出列表集(此较为关键):
[%JC%]=ListFor("客户档案","简称",1)
[%JC%]→一翻二
Eval("Substitute(""|@|"",""|"","""+Substitute([%JC%],"|",""")+""|""+Substitute(""|@|"",""|"",""")+""")")
2、写出最简单的循环命令。
ReplaceFor(Grid,"简称","A","进货单位","Instr","A") And ReplaceFor(Grid,"简称","B","进货单位","Instr","B")
3、把第2的命令粘贴到记事本中:
编辑→查找替换→在查找框输入:『"』→在在查找框输入:『""』→全部替换,得到 (此时列表为:A@A|B@B)
ReplaceFor(Grid,""简称"",""A"",""进货单位"",""Instr"",""A
(左拼部分) (A) (A@A及B@B間的“@”) (A)
"") And ReplaceFor(Grid,""简称"",""B"",""进货单位"",""Instr"",""B"")
右凑部分
(A|B間的“|”) (B)
4、用Substitute把第1的列表集中的分隔符“@”和“|”分別替换为 第3点字符集中的红色部分『"",""进货单位"",""Instr"",""』,和粉紅色部分『"") And ReplaceFor(Grid,""简称"",""』,
得到中间部分:
Substitute(Substitute(Eval("Substitute(""|@|"",""|"","""+Substitute([%JC%],"|",""")+""|""+Substitute(""|@|"",""|"",""")+""")")
,"@"," "",""进货单位"",""Instr"","""),"|",""") And ReplaceFor(Grid,""简称"",""")
5、加上『左拼部分』(第3中列表第一个字符前面所有字符)和『右凑部分』(第3中列表最后字符后面所有字符)
" ReplaceFor(Grid,""简称"","""+Substitute(Substitute(Eval("Substitute(""|@|"",""|"","""+Substitute([%JC%],"|",""")+""|""+Substitute(""|@|"",""|"",""")+""")")
,"@"," "",""进货单位"",""Instr"","""),"|",""") And ReplaceFor(Grid,""简称"",""")
+""")"
6、最后用Eval执行它,OK!
Eval(" ReplaceFor(Grid,""简称"","""+Substitute(Substitute(Eval("Substitute(""|@|"",""|"","""+Substitute([%JC%],"|",""")+""|""+Substitute(""|@|"",""|"",""")+""")")
,"@"," "",""进货单位"",""Instr"","""),"|",""") And ReplaceFor(Grid,""简称"",""")
+""")")