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 8664261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:12:00+00:00 2026-06-12T17:12:00+00:00

I am trying to make a cash register windows form (that would look like

  • 0

I am trying to make a cash register windows form (that would look like the picture below) and I KNOW I am overthinking this but I am really new to vb and really am confused by it all. But it just needs to add and subtract the balance. I need help figuring out how to do the math here, like since the user will enter all values how do we anticipate what they will enter in the code?

Here is what I have so far though:

Public Class frmCashRegister

    Dim Total As Decimal
    Dim Subtract As Decimal
    Dim Balance As Decimal


    Private Sub btnAdd_Click(sender As System.Object, e As System.EventArgs) Handles btnAdd.Click
        txtBalance.Text = FormatCurrency(Val(txtAmount.Text))
    End Sub

    Private Sub txtBalance_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtBalance.TextChanged
        If (txtBalance.Text < 0) Then
            MsgBox("Transaction resulted in negative balance, please try again!")
        End If
    End Sub

    Private Sub txtAmount_KeyPress(sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtAmount.KeyPress
        If Asc(e.KeyChar) <> 8 Then
            If Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57 Then
                e.Handled = True
            End If
        End If
    End Sub
End Class

enter image description here

  • 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-12T17:12:01+00:00Added an answer on June 12, 2026 at 5:12 pm

    First of all you need to screen all of your inputs to make sure that the user cannot enter anything that would cause an error. In the case of a simple cash register you need to make sure the the numbers, minus add and possibly the enter key works. As far as your Math you need to keep a variable with your running total in this case Balance you will then update this variable when you add and subtract your values and update your balance TextBox with the Value. Here is an idea on how to do it.

    Dim Total As Decimal
    Dim Subtract As Decimal
    Dim Balance As Decimal
    
    
    Private Sub btnAdd_Click(sender As System.Object, e As System.EventArgs) Handles btnAdd.Click
        Balance += Decimal.Parse(txtAmount.Text) 'Same as  Balance = Balance + Decimal.Parse(txtAmount.Text)
        txtBalance.Text = FormatCurrency(Balance)
        txtAmount.Text = ""
    End Sub
    
    
    Private Sub btnSubtract_Click(sender As System.Object, e As System.EventArgs) Handles btnSubtract.Click
        Balance -= Decimal.Parse(txtAmount.Text) 'Same as  Balance = Balance - Decimal.Parse(txtAmount.Text)
        txtBalance.Text = FormatCurrency(Balance)
        txtAmount.Text = ""
    End Sub
    
    Private Sub txtAmount_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtAmount.KeyPress
        If Asc(e.KeyChar) <> 8 AndAlso Asc(e.KeyChar) <> &H2E Then
            If Asc(e.KeyChar) = &H2B OrElse Asc(e.KeyChar) = &HD Then
                e.Handled = True
                btnAdd.PerformClick()
            ElseIf Asc(e.KeyChar) = &H2D Then
                e.Handled = True
                btnSubtract.PerformClick()
            ElseIf Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57 Then
                e.Handled = True
            End If
        End If
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to make a cash register like code, where the user
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
Trying to make a simple number clicker control for BlackBerry 6/7, like this: At
Trying to make a sphere. But it so doesn't look like 3D, in fact
I'm currently trying to make a form called countcash that allows users to input
I'm trying make a function that lists all subkeys of a specific (windows registry)
Trying to make a regex that can handle input like either: Beverly Hills, CA
I'm trying make an entity with doctrine that has three associations with other entities
im trying make one replace in string from a array but this dont work
I'm trying make my first python app. I want make simple email sender form.

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.