Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42215

VS 2010 How do I fix this code to output correctly?

$
0
0
I have code which will calculate the total price and then the change to be given back.

For example when the total is $1.00 and the payment given is $5.00, the change given back is $4.00 < works fine . Also when exact payment is entered, the code works fine calculating it.

However

When the payment is below the Total Cost (ex. $ 0.50) , It calculates the amount left to be paid ($0.50) in parentheses. which is correct, BUT

IF you type the amount left $0.50 or any other amount , It is adding UP the amount you type in.

Something is not working right. I can't seem to figure it out;

Here the code that I am using:

Code:


Dim Payment As String = ""
        Dim PaymentValue As Decimal = 0


        If CashPayment.Equals(True) Then
            PaymentValue = TextBoxItemInput.Text.ToString()
            If saletotal > PaymentValue Then

                TextBoxTotal.Text = FormatCurrency(PaymentValue - TextBoxTotal.Text.ToString)

                Update()
                Exit Sub
            End If
            TextBoxchange.Text = PaymentValue - saletotal
            Payment = PaymentValue.ToString


            LabelTotalandChange.Text = "CHANGE:"



            LineDisplay.ClearText()
            LineDisplay.DisplayText("CHANGE DUE: " & FormatCurrency(TextBoxTotal.Text) & "    THANK YOU!")

By the way Saletotal = textboxtotal.text

Viewing all articles
Browse latest Browse all 42215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>