3 Replies - 284 Views - Last Post: 28 October 2017 - 09:13 AM Rate Topic: -----

#1 RoastedRedPotatoes  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 28-October 17

Clearing Calculated Amount/Setting Back To ZERO

Posted 28 October 2017 - 08:10 AM

So my issue---it is probably a super simple fix---is that I have written the code to clear the calculated total/subtotal/taxamount. It is clearing it to $0.00. However, when I push a button to add something, it takes the previous calculation and adds that to the new total.

Example: 1st Total is $15, I clear the form, 2nd Total is $30---because it adds the $15 from the beginning.



Here is my RESET code:

 Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click
        'resets the selections


        btnReset.Enabled = False        'disables the reset button until a selection is made
        btnAppointment.Enabled = False  'disables the appointment button until a selection is made

        btnHaircut.Enabled = True       'enables buttons once restarted, they are disabled upon click
        btnPedicure.Enabled = True
        btnManicure.Enabled = True
        btnFacial.Enabled = True


        lblSubtotal.Text = ""          'Resets the totals for each to Null
        lblTotal.Text = ""
        lblTaxAmount.Text = ""

    End Sub
:code:

This post has been edited by modi123_1: 28 October 2017 - 09:06 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Clearing Calculated Amount/Setting Back To ZERO

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13491
  • View blog
  • Posts: 53,888
  • Joined: 12-June 08

Re: Clearing Calculated Amount/Setting Back To ZERO

Posted 28 October 2017 - 09:07 AM

It should be fairly straight forward to see where you have the other values hidden.. be it in a variable or textbox. Put a breakpoint there and see what variables are active and clear them out.

I cannot be more precise than that because I don't see the entire program.
Was This Post Helpful? 0
  • +
  • -

#3 RoastedRedPotatoes  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 28-October 17

Re: Clearing Calculated Amount/Setting Back To ZERO

Posted 28 October 2017 - 09:11 AM

View Postmodi123_1, on 28 October 2017 - 09:07 AM, said:

It should be fairly straight forward to see where you have the other values hidden.. be it in a variable or textbox. Put a breakpoint there and see what variables are active and clear them out.

I cannot be more precise than that because I don't see the entire program.



Sorry about that! I will post my entire code, maybe that will make it easier?

Public Class CapeFearSalon
    'Declarations


    Const _cdecHAIRCUT As Decimal = 5D          'Sets price for Haircut at $5.00
    Const _cdecMANICURE As Decimal = 10D        'Sets price for Manicure at $10.00
    Const _cdecPEDICURE As Decimal = 15D        'Sets price for Pedicure at $15.00
    Const _cdecFACIAL As Decimal = 8D         'Sets price for Facial at $8.00
    Const _cdecTAX_RATE As Decimal = 0.07D        'Sets tax rate amount at 7%
    Dim decSubtotal As Decimal = 0.0D           'Sets the starting subtotal at $00.00
    Dim decTotal As Decimal = 0.0D              'Sets the starting Total at $00.00
    Dim decTaxAmount As Decimal = 0.0D               'Sets the starting tax total at $00.00



    Private Sub btnHaircut_Click(sender As Object, e As EventArgs) Handles btnHaircut.Click
        btnHaircut.Enabled = False       'enable button
        btnAppointment.Enabled = True   'enables button upon click of a service
        btnReset.Enabled = True         'enable a reset upon a click of an incorrect service

        decSubtotal = decSubtotal + _cdecHAIRCUT               'Adds Haircut to Subtotal
        lblSubtotal.Text = decSubtotal.ToString("C")
        decTaxAmount = decTaxAmount + (_cdecHAIRCUT * _cdecTAX_RATE)            'Calculates the tax amount applied
        lblTaxAmount.Text = decTaxAmount.ToString("C")
        decTotal = decSubtotal + decTaxAmount                     'Adds the subtotal and tax amount applied together as one total
        lblTotal.Text = decTotal.ToString("C")

    End Sub

    Private Sub btnManicure_Click(sender As Object, e As EventArgs) Handles btnManicure.Click
        btnManicure.Enabled = False      'enable button
        btnAppointment.Enabled = True   'enables button upon click of a service
        btnReset.Enabled = True         'enable a reset upon a click of an incorrect service

        decSubtotal = decSubtotal + _cdecMANICURE              'Adds Manicure to Subtotal
        lblSubtotal.Text = decSubtotal.ToString("C")
        decTaxAmount = decTaxAmount + (_cdecMANICURE * _cdecTAX_RATE)           'Calculates the tax amount applied
        lblTaxAmount.Text = decTaxAmount.ToString("C")
        decTotal = decSubtotal + decTaxAmount                      'Adds the subtotal and tax amount applied together as one total
        lblTotal.Text = decTotal.ToString("C")
    End Sub

    Private Sub btnPedicure_Click(sender As Object, e As EventArgs) Handles btnPedicure.Click
        btnPedicure.Enabled = False      'enable button
        btnAppointment.Enabled = True   'enables button upon click of a service
        btnReset.Enabled = True         'enable a reset upon a click of an incorrect service

        decSubtotal = decSubtotal + _cdecPEDICURE              'Adds Pedicure to Subtotal
        lblSubtotal.Text = decSubtotal.ToString("C")
        decTaxAmount = decTaxAmount + (_cdecPEDICURE * _cdecTAX_RATE)           'Calculates the tax amount applied
        lblTaxAmount.Text = decTaxAmount.ToString("C")
        decTotal = decSubtotal + decTaxAmount
        lblTotal.Text = decTotal.ToString("C")         'Adds the subtotal and tax amount applied together as one total
    End Sub

    Private Sub btnFacial_Click(sender As Object, e As EventArgs) Handles btnFacial.Click
        btnFacial.Enabled = False        'enable button
        btnAppointment.Enabled = True   'enables button upon click of a service
        btnReset.Enabled = True         'enable a reset upon a click of an incorrect service

        decSubtotal = decSubtotal + _cdecFACIAL                'Adds Facial to Subtotal
        lblSubtotal.Text = decSubtotal.ToString("C")
        decTaxAmount = decTaxAmount + (_cdecFACIAL * _cdecTAX_RATE)             'Calculates the tax amount applied
        lblTaxAmount.Text = decTaxAmount.ToString("C")
        decTotal = decSubtotal + decTaxAmount                    'Adds the subtotal and tax amount applied together as one total
        lblTotal.Text = decTotal.ToString("C")
    End Sub

    Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click
        'resets the selections


        btnReset.Enabled = False        'disables the reset button until a selection is made
        btnAppointment.Enabled = False  'disables the appointment button until a selection is made

        btnHaircut.Enabled = True       'enables buttons once restarted, they are disabled upon click
        btnPedicure.Enabled = True
        btnManicure.Enabled = True
        btnFacial.Enabled = True


        lblSubtotal.Text = ""          'Resets the totals for each to Null
        lblTotal.Text = ""
        lblTaxAmount.Text = ""

    End Sub

    Private Sub btnAppointment_Click(sender As Object, e As EventArgs) Handles btnAppointment.Click
        lblThanks.Visible = True        'Appears on click of btnAppointment thanking customer for booking
        btnStart.Visible = True         'Appears on click, allows customer to restart form after booking
        btnStart.Enabled = True         'Enables btnStart
        btnHaircut.Visible = False      'Hides all previous pictures, buttons and text upon booking appointment
        btnManicure.Visible = False
        btnPedicure.Visible = False
        btnFacial.Visible = False
        btnReset.Visible = False
        btnAppointment.Visible = False
        picHaircut.Visible = False
        picManicure.Visible = False
        picPedicure.Visible = False
        picFacial.Visible = False
        lblHaircut.Visible = False
        lblPedicure.Visible = False
        lblManicure.Visible = False
        lblFacial.Visible = False
        lblSubtotal.Visible = False
        lblSubtotalText.Visible = False
        lblTotal.Visible = False
        lblTotalText.Visible = False
        lblTaxText.Visible = False
        lblTax.Visible = False
        lblTaxAmount.Visible = False              'end of hiding all pictures, buttons, and text from booking appointment


        btnHaircut.Enabled = True       'enables buttons once restarted, they are disabled upon click
        btnPedicure.Enabled = True
        btnManicure.Enabled = True
        btnFacial.Enabled = True



        lblSubtotal.Text = ""          'Resets the totals for each to Null
        lblTotal.Text = ""
        lblTaxAmount.Text = ""


    End Sub

    Private Sub btnStart_Click(sender As Object, e As EventArgs) Handles btnStart.Click
        lblThanks.Visible = False           'Hides the lblThanks and btnStart and opens form for new customer
        btnStart.Visible = False
        btnStart.Enabled = False
        btnHaircut.Visible = True           'Unhides all labels, buttons, and pictures for the next customer
        btnManicure.Visible = True
        btnPedicure.Visible = True
        btnFacial.Visible = True
        btnReset.Visible = True
        btnAppointment.Visible = True
        picHaircut.Visible = True
        picManicure.Visible = True
        picPedicure.Visible = True
        picFacial.Visible = True
        lblHaircut.Visible = True
        lblManicure.Visible = True
        lblPedicure.Visible = True
        lblFacial.Visible = True
        lblSubtotal.Visible = True
        lblSubtotalText.Visible = True
        lblTotal.Visible = True
        lblTotalText.Visible = True
        lblTaxAmount.Visible = True
        lblTaxText.Visible = True
        lblTax.Visible = True             'end of unhiding labels, buttons, and pictures for the next customer

        lblSubtotal.Text = ""          'Resets the totals for each to Null
        lblTotal.Text = ""
        lblTaxAmount.Text = ""

    End Sub

    Private Sub CapeFearSalon_Load(sender As Object, e As EventArgs) Handles Me.Load
        lblSubtotal.Text = ""          'Resets the totals for each to Null
        lblTotal.Text = ""
        lblTaxAmount.Text = ""
    End Sub
End Class


Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13491
  • View blog
  • Posts: 53,888
  • Joined: 12-June 08

Re: Clearing Calculated Amount/Setting Back To ZERO

Posted 28 October 2017 - 09:13 AM

Try the breakpoint method. This is a really good example to stretch some debugging skills!

Debugging
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1