Coding Cash register in VB.Net

Page 1 of 1

2 Replies - 15416 Views - Last Post: 09 May 2007 - 07:43 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=26976&amp;s=7648757bb77a70ef7f7e608001933e56&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 bud08girl

Reputation: 1
• Posts: 2
• Joined: 21-April 07

Coding Cash register in VB.Net

Posted 21 April 2007 - 05:40 PM

Hello- i am trying to code a gui similar to a cash register. I enter a price in a text box and click the enter button. I set a click event for the enter button so it will add the price entered to the subtotal. However, I can't seem to get the subtotal to save so the next item I enter will add to the subtotal. The following is the code (with comments) I have entered, if anyone can see what I am missing or have coded wrong, I would greatly appreciate it! There are no errors popping up and I am at a loss on what else I can try...Thanks so much!
``` 'declare the variables
Dim currentPrice As Integer
Dim subtotal As Decimal
Dim total As Decimal

'retrieve user input to calculate
currentPrice = Val(currentPriceTextBox.Text)
subtotal = Val(subtotalValueLabel.Text)

total = subtotal + currentPrice

If currentPrice > 0 Then
total = Val(subtotalValueLabel.Text) + currentPrice
End If

'display subtotal
subtotalValueLabel.Text = String.Format("{0:C}", total)

'clear item price box
currentPriceTextBox.Text = ""
```

Is This A Good Question/Topic? 1

Replies To: Coding Cash register in VB.Net

#2 Jayman

• Student of Life

Reputation: 421
• Posts: 9,532
• Joined: 26-December 05

Re: Coding Cash register in VB.Net

Posted 21 April 2007 - 06:00 PM

Where are you declaring the variables in your code?

You probably need to declare them at the Class level. If they are only declared in a procedure/function, then the variables only exist inside the scope of that procedure/function.

When the procedure/function has finished its' operations, the values are discarded.

#3 ramper04

Reputation: 1
• Posts: 12
• Joined: 13-December 06

Re: Coding Cash register in VB.Net

Posted 09 May 2007 - 07:43 PM

create a module and add global variables that will hold the values that are entered and then will also be able to retrieve those values when needed.