I tried to have this coded properly. It seems to returning all of the
correct answer but one never knows! Could someone please look at my
parentheses to see if they are correct.
Thank you
DS
Select Case Me.TxtCase
Case 1
Me.TxtAnswer = Qty * Price
Case 2
Me.TxtAnswer = (Qty * Price) * Tax
Case 3
Me.TxtAnswer = Qty * Price * (1 + Tax)
Case 4
Me.TxtAnswer = (Qty * Price) * Percent Discount
Case 5
Me.TxtAnswer = (Qty * Price) * (1 - Percent Discount)
Case 6
Me.TxtAnswer = Qty * Dollar Discount
Case 7
Me.TxtAnswer = Qty * (Price - Dollar Discount)
Case 8
Me.TxtAnswer = (Qty * Price) - (Tax * (Qty * Price))
Case 9
Me.TxtAnswer = Tax * (Qty * Price)
Case 10
Me.TxtAnswer = Qty * Price
Case 11
Me.TxtAnswer = (Qty * Price - (Tax * Qty * Price)) * Percent
Discount
Case 12
Me.TxtAnswer = (Qty * Price - (Tax * Qty * Price)) * (1 -
Percent Discount)
Case 13
Me.TxtAnswer = Qty * Dollar Discount
Case 14
Me.TxtAnswer = (Qty * Price - (Tax * Qty * Price)) - Qty *
Dollar Discount
End Select
How is someone expected to answer whether the parentheses are "correct" when
we have no idea what the desired results / logic are? The "correctness" of
the parentheses depends entirely upon what you are wanting the calculations
to do....and we would just be guessing without more information.

Signature
Ken Snell
<MS ACCESS MVP>
>I tried to have this coded properly. It seems to returning all of the
>correct answer but one never knows! Could someone please look at my
[quoted text clipped - 35 lines]
> Dollar Discount
> End Select
DS - 23 May 2008 05:30 GMT
Good Point. I just thought there was a Standard Order of things.
DS
scubadiver - 23 May 2008 12:05 GMT
You are correct.
http://en.wikipedia.org/wiki/Order_of_operations
but the calculations in your message are still a bit meaningless and you
don't specify what each case is intended to calculate
DS - 23 May 2008 16:37 GMT
Thanks Scuba Diver, I just asked John for the order of operations, I
couldn't remember the term when I needed it! Thank you for suppling it.
DS
Jan Baird - 27 May 2008 20:51 GMT
Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
Jan Baird - 27 May 2008 20:51 GMT
Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
Jan Baird - 27 May 2008 20:51 GMT
Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
>I tried to have this coded properly. It seems to returning all of the
>correct answer but one never knows! Could someone please look at my
[quoted text clipped - 35 lines]
>Dollar Discount
>End Select
Ken's point is well taken; nobody here could possibly have any idea what the
logical significance of txtCase might be, or whether your expressions in fact
match your business logic. It's supicious that Tax is used in two different
ways (in cases 2 and 3), and that cases 1 and 10 appear to be identical.
One thing that WILL be a problem is that blanks are meaningful. To VBA, Dollar
and Discount are two independent and unrelated variable names, likewise
Percent Discount. The program will look for variables named "Dollar" and
"Percent" and "Discount" and fail. If these are VBA variables, they cannot
contain blanks; try DollarDiscount and PercentDiscount. If they refer to form
controls, use square brackets: [Dollar Discount], or better, rename the
control to eliminate the blank.

Signature
John W. Vinson [MVP]
DS - 23 May 2008 16:30 GMT
Thanks John, I see the Err of my ways. I appreciate the input about the
blanks. By the way what is the order of operations in math?
Thanks
DS
John W. Vinson - 23 May 2008 20:04 GMT
>Thanks John, I see the Err of my ways. I appreciate the input about the
>blanks. By the way what is the order of operations in math?
Multiplication and division first, addition and subtraction afterward. I'd be
inclinde to freely use parentheses to make it unambiguous; I'm sure that
A * B + C
will be equivalent to
(A * B) + C
rather than to
A * (B + C)
but it would be clearer and self-documenting if you use the parenthesized
notation.

Signature
John W. Vinson [MVP]
DS - 27 May 2008 16:51 GMT
Thanks John, I agree with you. I think the parentheses will work better.
DS
Jan Baird - 27 May 2008 20:52 GMT
Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
Jan Baird - 27 May 2008 20:51 GMT
Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
Jan Baird - 27 May 2008 20:51 GMT
Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.