Comment every line in this code.... whatever that means? Please help! dim price1
ID: 3546483 • Letter: C
Question
Comment every line in this code.... whatever that means? Please help!
dim price1, price2, price3 as decimal
dim subtotal, discount, disAmount, disSubtotal, taxDue, total as decimal
price1 = val (txtPrice1.text)
price2 = val (txtPrice2.text)
price3 = val (txtPrice3.text)
subtotal = price1 + price2 + price3
if (subtotal >= 5000) then
discount = .15
else if (subtotal >= 25000 andalso subtotal <5000) then
discount = .10
else
discount = .05
end if
disAmount = subtotal * discount
disSubtotal = subTotal - disAmount
if (chkLocal.checked = true) then
disSubtotal = disSubTotal- (disSubTotal * .02)
end if
lblSubtotal.text = subtotal.tostring("c")
lblDisSubtotal.text = disSubtotal.tostring("c")
lblTaxDue.text = taxDue.toString("c")
lblTotal.text = total.toString ("c")
Explanation / Answer
//declaring variables of required type . Dim means dimention
dim price1, price2, price3 as decimal
dim subtotal, discount, disAmount, disSubtotal, taxDue, total as decimal
//assigning declare variables
price1 = val (txtPrice1.text)
price2 = val (txtPrice2.text)
price3 = val (txtPrice3.text)
subtotal = price1 + price2 + price3
//if loop to do some calculation for getting discount based on subtotal
if (subtotal >= 5000) then
discount = .15
else if (subtotal >= 25000 andalso subtotal <5000) then
discount = .10
else
discount = .05
end if
disAmount = subtotal * discount
disSubtotal = subTotal - disAmount
//verifying condition & going on
if (chkLocal.checked = true) then
disSubtotal = disSubTotal- (disSubTotal * .02)
end if
//assigning the values genrated from input to controls (textbox,label etc)
lblSubtotal.text = subtotal.tostring("c")
lblDisSubtotal.text = disSubtotal.tostring("c")
lblTaxDue.text = taxDue.toString("c")
lblTotal.text = total.toString ("c")