Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm making an application to display the total price of a order. It decides the price based on the number of items ordered and if the customer is a wholesale or retailer.

Calculation it uses:

1-4 items = $10 per item if wholesaler.

5+ items = $9 each if wholesaler.

1-3 items = $15 per item if retailer.

4-8 item = $14 per item if retailer.

9+ item = $12 per item if retailer. I'm stuck on the calculation and confused as to how I would do it.

The GUI is complete, here is what I have so far:

Picture of GUI: http://i.imgur.com/P2tDz.png

Dim quantity As Decimal
Dim price As Decimal
Dim wholesaler As Integer
Dim retailer As Integer

Integer.TryParse(txtUnits.Text, price)

chkRetailer.Text = retailer
chkWholesale.Text = wholesaler


If wholesaler Then
    If Quantity <= 4 Then
        Price = 10
    Else
        Price = 9
    End If
ElseIf retailer Then
    If Quantity <= 3 Then
        Price = 15
    ElseIf Quantity <= 8 Then
        Price = 14
    Else
        Price = 12
    End If
End If

lblTotPrice.Text = price * quantity

lblTotPrice.Text = price.ToString("C0")

It's the calculation I'm confused on, I have the display and the declarations correct I believe.

Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
197 views
Welcome To Ask or Share your Answers For Others

1 Answer

This would be much clearer using Case statements (The VB example of the link provided is very helpful)

First use an IF statement to determine if you are a wholesaler and that determines which of the two case statements assigns the valid price


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...