VB.NET How to add numbers in a textbox

zer0punk
05-22-2006, 03:37 PM
I am working on a project that requires me to have a onscreen reciept in a windows form. When someone hits the drink button it putts drink and the amount in the text box then if you hit it a secound time it will put another drink and price below it. I want to be able to add those numbers up and put the sum in textbox2 then it add the tax IE .09 and show the taxes in textbox3 and then add the subtotal to the taxes and give me the grand total in textbox4.

Here is the code that I have now:

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'HIDING THE TOP MID AND BOTTUM SHELF LIQUIORS

Button5.Visible = False
Button6.Visible = False
Button7.Visible = False
'END OF THE LIQUIOR HIDES

End Sub




Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Button5.Visible = True
Button6.Visible = True
Button7.Visible = True
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Button5.Visible = True
Button6.Visible = True
Button7.Visible = True
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Button5.Visible = False
Button6.Visible = False
Button7.Visible = False
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Button5.Visible = False
Button6.Visible = False
Button7.Visible = False
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Button5.Visible = False
Button6.Visible = False
Button7.Visible = False
End Sub


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

TextBox1.Text = TextBox1.Text + vbCrLf + "beer $3.29"





End Sub

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged


End Sub
End Class
Thanks I have been racking my brain and searching I have not found any examples.

K :confused:

Moohasha
05-22-2006, 05:09 PM
It would probably be way easier to just have some variable that keeps a total of all the drinks that gets updated each time the button is clicked rather than trying to add up values from a textbox (that also includes text). Also, I'd recomend a ListBox instead of a TextBox. You can just use the Add() method to insert a new line, and it's more of an itenerary than a TextBox.
So just add the following line to your Button1.Click event, and I'm sure you can figure out the displaying the total and taxes and everything from that:

' Total defined globaly
Total += 3.29

zer0punk
05-22-2006, 07:39 PM
the prob that I have with the var is there is going to be alot more than just this one button for drinks. I am still kindah new ao If you could elude more on the var. and how to make the var do the math. to come up with not the total in drinks but the total cost.

Cheers....
K

zer0punk
05-23-2006, 09:37 AM
I hope someone's not paying you to do this.
No just doing it for fun trying to teach myself to program. I plain on releasing it as freeware. I will just figure it out. thanks for the speedy replies. I am a network admin. This is all still new to me. Sorry

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum