Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7781123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:07:33+00:00 2026-06-01T19:07:33+00:00

My accumulator (decTotalCredits) is not working properly and is resetting to zero with each

  • 0

My accumulator (decTotalCredits) is not working properly and is resetting to zero with each entry. I am needing the accumulator to add in each user input until it hits 125. As it normally is, I’m sure it’s something small. Thanks in advance for all your help!

    ' Declaring variable for Credit Entered by User
    Dim decCredit As Decimal = CDec(txtCredit.Text)
    ' Declaring the accumulator
    Dim decTotalCredits As Decimal

    If IsNumeric(txtCredit.Text) Then
        decCredit = Convert.ToDecimal(txtCredit.Text)
        Select Case decCredit
            Case Is = 5
            Case Is = 10
            Case Is = 25
            Case Is = 100
            Case Else
                MsgBox("Please enter a valid coin amount", , "Invalid Amount Entered")
        End Select

        If decTotalCredits < 125 Then

            decTotalCredits += decCredit
            lblTotal.Text = CStr(decTotalCredits)
            lblTotal.Visible = True

            txtCredit.Clear()
            txtCredit.Focus()

        Else

            ' Once the credits are reached the prompt to make selection is visible. 
            lblMakeSelection.Visible = True

            ' Once the credits are reached, the buttons for selection become enabled.
            btnDietPepsi.Enabled = True
            btnPepsi.Enabled = True
            btnSierraMist.Enabled = True
            btnLemonade.Enabled = True
            btnDrPepper.Enabled = True
            btnWater.Enabled = True
        End If
    Else
        MsgBox("Please enter a valid Coin amount", , "Input Error")


    End If
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:07:34+00:00Added an answer on June 1, 2026 at 7:07 pm

    It’s being redeclared..

    • If this is in a loop you need to declare DecTotalCredits outside of your loop.
    • If this is in an event handler you need to declare DecTotalCredits At the top of your code (right below the declaration of the class) That way it doesn’t get redeclared everytime the handler runs
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to replace pieces of XML and need an accumulator along the way.
For example, the accumulator is named EAX and, while the instruction pointer is called
I have read that in 8085 the accumulator is a 8 bit register. Then
I've got a class, Accumulator, that implements the Comparable compareTo method, and I'm trying
I'm making a function that concatenates ternary trees of lists, using an accumulator. 19
With Boost's accumulators I can easily calculate statistical quantities for weighted or unweighted input
I have a system that tracks what documents users view. Each document has its
i'm coding a 4-bit binary adder with accumulator: library ieee; use ieee.std_logic_1164.all; entity binadder
I have such controller: def accumulators @pre_accums = Accumulator.all @accums = Kaminari.paginate_array(@pre_accums).page(params[:page]).per(20) end and
My code leaks but I do not know exactly what am I doing wrong.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.