以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 这样的比对结果如何才能实现 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=178308) |
||||
-- 作者:rongping -- 发布时间:2022/6/29 9:08:00 -- 这样的比对结果如何才能实现 老师您好!我有一个表,表中有一个配方列。我想对几个配方进行对比,然后用两个临时列比对结果,该怎样实现? 比如我有三个配方别是: 配方一:苹果9g,香蕉9g,西瓜6g,葡萄6g 配方二:橘子9g,苹果6g,芒果6g,西瓜3g 配方三:牛奶12g,橘子9g,苹果6g,西瓜9g,葡萄6g,芝士6g 比对结果分为两列,以第一个配方为基础 第一列配方二后面为 苹果少3克,西瓜少3克 配方三后面为 苹果少3克,西瓜多3克 第二列配方二后面为 没有香蕉,葡萄,多橘子,芒果 配方三后面为 没有香蕉,多牛奶,橘子,芝士 请问如何才能实现? |
||||
-- 作者:y2287958 -- 发布时间:2022/6/29 9:17:00 -- 上项目文件 |
||||
-- 作者:有点蓝 -- 发布时间:2022/6/29 9:38:00 -- Dim s1 As String = "苹果9g,香蕉9g,西瓜6g,葡萄6g" Dim s2 As String = "橘子9g,苹果6g,芒果6g,西瓜9g" Dim p As String = "[\\u4e00-\\u9fa5]" Dim str As String = "" For Each s As String In s1.Split(",") Dim g As String = System.Text.RegularExpressions.Regex.Replace(s , p , "") Dim n As String = s.Replace(g, "") If s2.Contains(n) Then For Each m As String In s2.Split(",") If m.Contains(n) Then Dim g2 As String = System.Text.RegularExpressions.Regex.Replace(m , p , "") Dim k1 As String = Val(g) Dim k2 As String = Val(g2) If k1 <> k2 Then str = str & "," & n & IIf(k1 > k2, "少", "多") & Math.Abs(k1 - k2) & "克" End If End If Next End If Next str = str.Trim(",") Output.Show(str)
|
||||
-- 作者:rongping -- 发布时间:2022/6/29 18:46:00 --
实现不了,请求帮助
|
||||
-- 作者:有点蓝 -- 发布时间:2022/6/30 8:53:00 --
|
||||
-- 作者:rongping -- 发布时间:2022/6/30 19:26:00 --
老师!后面的成分对比还要帮我搞定一下
|
||||
-- 作者:有点蓝 -- 发布时间:2022/6/30 20:42:00 -- 成分对比和数量对比有什么区别?按什么规则计算? |
||||
-- 作者:rongping -- 发布时间:2022/6/30 21:16:00 -- 成分对比是对比两个配方的材料,比如配方一有苹果,而配方三没有苹果,但多了芝士。这个没有的和多的材料要显示在成分对比列 |
||||
-- 作者:有点蓝 -- 发布时间:2022/6/30 22:04:00 -- Dim s1 As String = "苹果2克,芒果9克,葡萄9克" Dim p As String = "[\\u4e00-\\u9fa5]" For Each r As Row In Tables("配方表").rows Dim str As String = "" Dim str2 As String = "" Dim lst As New List(Of String) Dim lst2 As New List(Of String) Dim cf As Boolean = False For Each s As String In s1.Split(",") Dim g As String = System.Text.RegularExpressions.Regex.Replace(s , p , "") Output.Show(g) Dim n As String = s.Replace(g, "").Replace("克", "") Dim k1 As String = Val(g) Output.Show("n--------" & n & ",k1=" & k1) If r("成分").Contains(n) Then lst.Add(n) For Each m As String In r("成分").Split(",") Output.Show("m=" & M) Dim g2 As String = System.Text.RegularExpressions.Regex.Replace(m , p , "") If cf = False Then lst2.Add(m.Replace(g2, "").Replace("克", "")) End If If m.Contains(n) Then Dim k2 As String = Val(g2) Output.Show("--g2=" & g2 & ",k2=" & k2) If k1 <> k2 Then str = str & "," & n & IIf(k1 > k2, "少", "多") & Math.Abs(k1 - k2) & "克" Output.Show("str=" & str) End If End If Next cf = True Else str2 = str2 & ",少了" & n End If Next str = str.Trim(",") For Each a As String In lst2 If lst.Contains(a) = False Then str2 = str2 & ",多了" & a End If Next r("数量对比") = str r("成分对比") = str2 Next
|
||||
-- 作者:rongping -- 发布时间:2022/7/1 22:14:00 -- 以下是引用有点蓝在2022/6/30 22:04:00的发言: Dim s1 As String = "苹果2克,芒果9克,葡萄9克" Dim p As String = "[\\u4e00-\\u9fa5]" For Each r As Row In Tables("配方表").rows Dim str As String = "" Dim str2 As String = "" Dim lst As New List(Of String) Dim lst2 As New List(Of String) Dim cf As Boolean = False For Each s As String In s1.Split(",") Dim g As String = System.Text.RegularExpressions.Regex.Replace(s , p , "") Output.Show(g) Dim n As String = s.Replace(g, "").Replace("克", "") Dim k1 As String = Val(g) Output.Show("n--------" & n & ",k1=" & k1) If r("成分").Contains(n) Then lst.Add(n) For Each m As String In r("成分").Split(",") Output.Show("m=" & M) Dim g2 As String = System.Text.RegularExpressions.Regex.Replace(m , p , "") If cf = False Then lst2.Add(m.Replace(g2, "").Replace("克", "")) End If If m.Contains(n) Then Dim k2 As String = Val(g2) Output.Show("--g2=" & g2 & ",k2=" & k2) If k1 <> k2 Then str = str & "," & n & IIf(k1 > k2, "少", "多") & Math.Abs(k1 - k2) & "克" Output.Show("str=" & str) End If End If Next cf = True Else str2 = str2 & ",少了" & n End If Next str = str.Trim(",") For Each a As String In lst2 If lst.Contains(a) = False Then str2 = str2 & ",多了" & a End If Next r("数量对比") = str r("成分对比") = str2 Next
真实项目是这个,但是在方剂对比窗口的方剂对比按钮,结果还是不对,希望版主能够帮我改正一下。
|