Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VB. Help with percentage.
#2
A simple way to handle this is:
Code:
Private Sub CalcRetail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalcRetail.Click Dim curWholesale, curRetail as Currency, decMarkup As Decimal

curWholesale = txtWholesale.Text
decMarkup = txtMarkup.text / 100
If decMarkup < 0 Then
MsgBox("Markup percentage cannot  be lower than 0%.")
End If
curRetail = curWholeSale * decMarkup
lblRetail.Text = curRetail
End Sub

Excuse me if my coding is dirty, I haven't touched this in two years. Also, if you want to allow negative markups, you may want to remove that MsgBox line but do something else to prevent negative curRetail, like:
Code:
If curRetail < 0 Then
curRetail = 0
End If
Reply


Messages In This Thread
VB. Help with percentage. - by Khoi - 2010-11-11, 05:01 PM
VB. Help with percentage. - by Jedward - 2010-11-11, 05:32 PM
VB. Help with percentage. - by Khoi - 2010-11-11, 05:34 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)