Home > Net >  Calculated values according to the scope of the keywords and the results (automatic carton packing q
Calculated values according to the scope of the keywords and the results (automatic carton packing q

Time:01-27

There is a basic data table a, contain different item (goods), different type (the size of the carton), can pack the goods how much is the maximum and the minimum respectively,
Item type maxQty minQty
A1 20 16 1
A1 2 15 10
A1 3 9 6
A1 3, 4, 5
A2 18 15 1
A2 2 14 12
A2 3 11 8
A2 4 7 5
A3 12 October 1
A3 2 9 7
A3 3 6 4
A3 4 3 2
.

Have an order table b, containing each Po, the goods name and quantity of the goods
Po item qty
A001 a1 44
A002 a1 15
A003 a2 100
A0004 a2 19
.

Default each goods, with the type of 1 carton (largest size box), when all after the shipment, tail again for 2 and 4 with the type of case to pack, how to calculate these orders to how many cartons?

I intend to use a loop to calculate the type 1 carton (largest size) to use how many, calculate the remainder after the modQty is divisible, but different item minQty and maxQty is different, the remainder can not directly together, do you have any good idea?

Dim poQty as an integer, minQty as an integer, maxQty as an integer, CtnQty as an integer, modQty integer
Poqty=0
MinQty=0
MaxQty=0
CtnQty=0
ModQty=0

For I as integer=0 to b.r ows. Count - 1
A. d. efaultview. Rowfilter="item='" b.r ows (I) (" item") "' and type=1 "

If a. d. efaultview. Count=1 then
PoQty=b.R ows (I) (" Qty ")
MinQty=a. d. efaultView. Item (0) (" MinQty ")
MaxQty=a. d. efaultView. Item (0) (" MaxQty ")
If poQty Mod MaxQty=0 Then
CtnQty=poQty/MaxQty
ElseIf poQty Mod MaxQty & gt; MinQty Then
CtnQty=Math. Floor (poQty/MaxQty) + 1
ModQty=poQty Mod MinQty
The Else
ModQty=poQty Mod MaxQty
End the If
End the if
Next I

  • Related