Hello! I'm new to VB and I'm having trouble finding the correct formula for the Average Discount :'(
Option Explicit
Dim mcurExtendedPrice As Currency
Dim mcurFifteenDiscount As Currency
Dim mcurDiscountedPrice As Currency
Dim mcurTotalDiscountGiven As Currency
Dim mcurBookCount As Currency
'Declare module-level variables
Private Sub cmdCompute_Click()
Dim intQuantity As Integer
Dim curPrice As Currency
Dim curAverageDiscount As Currency
Const curFifteenDiscount As Currency = 0.15
'Declare the local variables
intQuantity = Val(txtQuantity.Text)
curPrice = Val(txtPrice.Text)
'Convert text to numbers
mcurExtendedPrice = curPrice * intQuantity
mcurFifteenDiscount = mcurExtendedPrice * curFifteenDiscount
mcurDiscountedPrice = mcurExtendedPrice - mcurFifteenDiscount
mcurBookCount = mcurBookCount + intQuantity
mcurTotalDiscountGiven = mcurTotalDiscountGiven + mcurFifteenDiscount
curAD = ????Help???
'Calculate
lblEP.Caption = mcurExtendedPrice
lblF.Caption = mcurFifteenDiscount
lblDP.Caption = mcurDiscountedPrice
lblBC.Caption = mcurBookCount
lblTD.Caption = mcurTotalDiscountGiven
lblAD.Caption = curAverageDiscount
'Display
lblEP.Caption = FormatNumber(mcurExtendedPrice, 2)
lblF.Caption = FormatNumber(mcurFifteenDiscount, 2)
lblDP.Caption = FormatNumber(mcurDiscountedPrice, 2)
lblTD.Caption = FormatNumber(mcurTotalDiscountGiven, 2)
lblAD.Caption = FormatNumber(curAverageDiscount, 2)
txtP.Text = FormatCurrency(curPrice, 2)
'Format
End Sub
Private Sub cmdEnd_Click()
End
End Sub
Private Sub Command2_Click()
lblEP.Caption = ""
lblF.Caption = ""
lblDP.Caption = ""
txtP.Text = ""
txtQ.Text = ""
End Sub
If I put $10 as quantity and $500 as the price for the first transaction, the average discount should be $750.00. If I put $20 as quantity and $1000 as the price for the second transaction, the average discount should be $1875. If I put $25 in the quantity and $250 for price, the average discount should be $1562. Pls. help ASAP :'(. Still learning.