Advertisement
NAK

CalculateRetail

NAK
Oct 31st, 2013
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.00 KB | None | 0 0
  1.     Function ValidateInput(inPut As Object) As Boolean
  2.  
  3.         If IsNumeric(inPut) Then
  4.             Return inPut > 0
  5.         Else
  6.             Return False
  7.         End If
  8.  
  9.     End Function
  10.  
  11.     Function CalculateRetail(WholesaleCost As Decimal, MarkUppercentage As Integer) As Decimal
  12.         ' calculate the retail price
  13.         Return WholesaleCost * ((MarkUppercentage / 100) + 1)
  14.     End Function
  15.  
  16.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  17.         ' Validate user inpout
  18.  
  19.         If Not ValidateInput(wholesale.Text) Then
  20.             System.Windows.Forms.MessageBox.Show("Please enter a valid Retail Price")
  21.             Exit Sub
  22.         End If
  23.         If Not ValidateInput(markup.Text) Then
  24.             System.Windows.Forms.MessageBox.Show("Please enter a positive MarkUp Percentage 1 - 100")
  25.             Exit Sub
  26.         End If
  27.         ' Calculate Retail Price
  28.         Label1.Text = "$" & CalculateRetail(wholesale.Text, markup.Text)
  29.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement