Home > Software engineering >  For help: using the VB code, according to the records of order statistics
For help: using the VB code, according to the records of order statistics

Time:09-20

Mf1 for display controls MSFlexGrid name
Db_sjk. MDB to access database
Tb_in for the data table, "name of commodity", "warehouse number", "put in storage unit price" for the field name

Database link: the Provider=Microsoft. Jet. The OLEDB. 4.0; Data Source="& amp; App. The Path & amp; "\ db_sjk. MDB; Persist Security Info=False

Help problem:

Using the VB code, according to the outbound order mf1. TextMatrix (I, 2) the "name of commodity," mf1. TextMatrix (I, 3) the "quantity", from "tb_in data table", according to the commodity warehousing registration order, statistical goods with the same total outbound, in mf1. TextMatrix (I, 4)

Outbound calculation of the total, it is according to order goods warehousing registration "storage quantity" * "storage unit price" (e.g., illustrations)



CodePudding user response:

Ha ha, actually is nonlinear database table,

CodePudding user response:

reference 1st floor of123 response:
ha ha, actually is non-linear database table,
new to vb, many things are modeled on some examples of learning by doing, and look forward to get the old drivers counsel

CodePudding user response:

In using excel vba code, a simple search and calculation in the form of progressive, can easily achieve effect, query and statistic share vba code, I do not know whether can reference

 Sub LQXS () 

Dim arr, j& , i& BRR, aa, sl, je, zje, ca
Dim d, k, t, tt
The Set d=CreateObject (" scripting. The dictionary ")
Sheet1. Activate
[r]. D4: d20 ClearContents
Arr=Sheet4. [a1]. CurrentRegion
For I=3 To UBound (arr)
D (arr (I, 2))=d (arr (I, 2)) & amp; I & amp; ", "
Next
K=d.k eys: t=d.i tems
BRR=[a1] CurrentRegion
For I=4 To UBound (BRR)
If BRR (I, 2) & lt;> "" Then
Sl=BRR (I, 3)
Zje=0
If d.e xists (BRR (I, 2)) Then
Tt=d (BRR (I, 2))
Tt=Left (tt, Len (tt) - 1)

Aa=Split (tt, ", ")
For j=0 To UBound (aa)
Ca=sl - arr (aa (j), 3)
If the ca & lt; 0 Then
Zje=zje + sl * arr (aa (j), 4)
The Exit For
The Else
Zje=zje + arr (aa (j), 3) * arr (aa (j), 4)
Sl=ca
End the If
Next
The Else

End the If
Cells (I, 4)=zje
The Else
The Exit For
End the If
Next
End Sub

CodePudding user response:

Don't understand, why must be in order, direct the water out of a certain period of time, accumulative rolling difference once finished, don't need to pipe order

CodePudding user response:

Chewinggum
reference 4 floor response:
didn't understand, why must be in order, direct the water out of a certain period of time, accumulative rolling difference once finished, don't need to pipe order.
may be different, because of the price of each incoming batches purpose is to achieve fifo, then statistical outbound amount

CodePudding user response:

That is put in storage batches according to time sequence, outbound time


Each outbound records,

Dim sum outbound amount
For I=1 to record Numbers less than warehouse outbound number
If incoming record I (the amount of inventory quantity - dispatch) less than or equal to the delivery
Outbound number=number of put in storage, the number of outbound - warehousing record I
Inventory records I mark dispatch quantity=storage quantity
Cumulative outbound amount=amount accumulative outbound amount + storage amount
The else
Inventory records I mark dispatch number=inventory records I mark dispatch number + delivery
The delivery=0
Cumulative outbound amount=amount accumulative outbound + delivery * the unit price of inventory records I
Exit the loop
End the if
Next
Output accumulative amount of outbound

CodePudding user response:

refer to 6th floor chewinggum response:
that is put in storage batches according to time sequence, outbound time


Each outbound records,

Dim sum outbound amount
For I=1 to record Numbers less than warehouse outbound number
If incoming record I (the amount of inventory quantity - dispatch) less than or equal to the delivery
Outbound number=number of put in storage, the number of outbound - warehousing record I
Inventory records I mark dispatch quantity=storage quantity
Cumulative outbound amount=amount accumulative outbound amount + storage amount
The else
Inventory records I mark dispatch number=inventory records I mark dispatch number + delivery
The delivery=0
Cumulative outbound amount=amount accumulative outbound + delivery * the unit price of inventory records I
Exit the loop
End the if
Next
Output cumulative outbound amount
hello teacher, due to the tight for vb code also study, your this way, with how to write code, thank you

CodePudding user response:

Is my vb knowledge level is too low? Or the problem is difficult? Looking forward to get a satisfactory answer
  • Related