Thursday, June 13, 2013

Function- New Price

Public Class Form1
    Dim dblNewPrice As Double
    Dim dblCurrentPrice As Double
    Private Function GetNewPrice(ByVal dblPrice As Double) As Double
        'Increases the current price by 5% and returns the new price
        dblPrice = dblPrice * 1.05
        Return dblPrice
    End Function


    Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
        Double.TryParse(txtCurrentPrice.Text, dblCurrentPrice)
        dblNewPrice = GetNewPrice(dblCurrentPrice)
        lblNewPrice.Text = dblNewPrice.ToString("c2")
    End Sub

    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub
End Class