Dim bza As Double = 9.97
Dim bzb As Double = 34.34
Dim bzc As Double = 17.8
Dim r1 As DataRow = DataTables("表A").Find("物料='A'")
Dim r2 As DataRow = DataTables("表A").Find("物料 = 'B'")
Dim r3 As DataRow = DataTables("表A").Find("物料 ='c'")
Dim x As Double
Dim y As Double
Dim c As Double
Dim maxa As Double = 100
Dim maxb As Double = 100
Dim maxc As Double = 100
For x = 0 To maxa
For y = 0 To maxb
For c = 0 To maxc
If (r1("蛋白") * x + r2("蛋白") * y + r3("蛋白") * c) <= bza * 100 + 1 _
AndAlso(r1("蛋白") * x + r2("蛋白") * y + r3("蛋白") * c) >= bza * 100 - 1 _
AndAlso (r1("含油") * x + r2("含油") * y + r3("含油") * c) <= bzb * 100 + 1 _
AndAlso (r1("含油") * x + r2("含油") * y + r3("含油") * c) >= bzb * 100 - 1 _
AndAlso (r1("水分") * x + r2("水分") * y + r3("水分") * c) <= bzc * 100 + 1 _
AndAlso (r1("水分") * x + r2("水分") * y + r3("水分") * c) >= bzc * 100 - 1 _
AndAlso x + y + c = 100 Then
Dim dr As DataRow = DataTables("表B").AddNew
dr("第一列") = x / 100
dr("第二列") = y / 100
dr("第三列") = c / 100
End If
Next
Next
Next
感觉没问题,但实际有一组解 就是计算不到,不知道错在哪里了