Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Private Sub txt_a_qty_TextChanged(sender As Object, e As EventArgs) Handles txt_a_qty.TextChanged
txt_a_qty.Text = Val(txt_b_qty.Text) - Val(txt_so_qty.Text)
End Sub


this is mean the available quantity equal the buyed quantity minus the sold quantity... what is the right code to not exceed the sold quantity than the available quantity?

What I have tried:

VB
Private Sub txt_a_qty_TextChanged(sender As Object, e As EventArgs) Handles txt_a_qty.TextChanged
txt_a_qty.Text = Val(txt_b_qty.Text) - Val(txt_so_qty.Text)
End Sub
Posted
Updated 8-Jun-22 17:59pm
v2

1 solution

Look at the Math.Min operator:
VB
mostYouCanHave = Math.Min(qtyInStock, qtyOrdered)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900