stuck on some visual basic

Associate
Joined
7 Nov 2004
Posts
1,755
Location
Southampton/Oxford
have some problems working out how to do this, bit of pickle when it coems to programming, basically trying to work out the total amount of items sold right, so far me and a friend have worked out to have a loop running and flag the current calculation, till the user has finished, at the moment i have 4 txt boxes and this is the coding i have so far

MessageBox.Show("Please record the results in the Total Sales File", "Read me", MessageBoxButtons.OK)

Dim Price, Quantity, Total As Decimal
Dim Answer As Decimal

Price = Val(TxtPrice.Text)
Quantity = Val(TxtQuantity.Text)
Total = Val(TxtAnswer.Text)
Answer = Val(TxtAnswer.Text)

Total = Price * Quantity

TxtAnswer.Text = "" & Answer

any help would be appreciated :confused:
 
Here is what I *think* you want, based on my understanding of what you're trying to acheive. I'm not sure what the difference between Total and Answer is?

Perhaps if you post some more detail, I may be able to help more.

Code:
MessageBox.Show("Please record the results in the Total Sales File", "Read me", MessageBoxButtons.OK)

Dim Price, Quantity, Total, Answer As Decimal

Price = Val(TxtPrice.Text)
Quantity = Val(TxtQuantity.Text)
'Total = Val(TxtAnswer.Text) - don't think you need this line, yet
Answer = Val(TxtAnswer.Text)

Total = Price * Quantity

TxtAnswer.Text = CStr(Total)
 
Yeah that is a bit of a wooly description. cound you explain the problem a bit better and im sure we will be able to help.
 
Code:
MessageBox.Show("Please record the results in the Total Sales File", "Read me", MessageBoxButtons.OK)

Dim Price, Quantity, Total, Answer As Decimal

Price = Val(TxtPrice.Text)
Quantity = Val(TxtQuantity.Text)

Total = Price * Quantity


TxtAnswer.Text = Total

That will take your quantity and price and give you a total. That total will then be put into the answer text box.
 
Back
Top Bottom