George Hallam
10-23-2008, 10:05 AM
Ok the question i have is
The shipshape packing company wants a program for their orders department to calculate and display the price of an order. The order clerks enter the number of units ordered, weather a customer is a wholesaler or a retailer, weather or not the customer is a special customer. Use a variety of controls for this data entry. The price the customer pays per unit depends on these three things the prices are
for wholesaler
1-5 units = $50
6-10 units = $45
11-20 units = $40
21-50 units = $35
over 50 units = $30
for retailers
1-3 units = $60
4-8 units = $55
9-15 units = $50
16-40 units = $45
over 40 units = $40
special customers get a discount of 10%
now i have a problem here is my code so far and the design
Option Explicit
Dim number_of_units As Integer
Dim whole_sale_price As Single
Dim retail_price As Single
Dim total As Single
Dim specail As Single
Private Sub cmdcalc_Click()
number_of_units = txtunits.Text
If number_of_units <= 5 Then
If optwhole.Value = True Then
whole_sale_price = 50
txttotal.Text = number_of_units * whole_sale_price
Else
If number_of_units <= 3 Then
If optretail.Value = True Then
retail_price = 60
txttotal.Text = number_of_units * retail_price
End If
End If
End If
Else
If number_of_units <= 10 Then
If optwhole.Value = True Then
whole_sale_price = 45
txttotal.Text = number_of_units * whole_sale_price
Else
If number_of_units <= 8 Then
If optretail.Value = True Then
retail_price = 55
txttotal.Text = number_of_units * retail_price
End If
End If
End If
Else
If number_of_units <= 20 Then
If optwhole.Value = True Then
whole_sale_price = 40
txttotal.Text = number_of_units * whole_sale_price
Else
If number_of_units <= 15 Then
If optretail.Value = True Then
retail_price = 50
txttotal.Text = number_of_units * retail_price
End If
End If
End If
Else
If number_of_units <= 50 Then
If optwhole.Value = True Then
whole_sale_price = 35
txttotal.Text = number_of_units * whole_sale_price
Else
If number_of_units <= 40 Then
If optretail.Value = True Then
retail_price = 45
txttotal.Text = number_of_units * retail_price
End If
End If
End If
If number_of_units > 50 Then
If optwhole.Value = True Then
whole_sale_price = 30
txttotal.Text = number_of_units * whole_sale_price
Else
If number_of_units > 40 Then
If optretail.Value = True Then
retail_price = 40
txttotal.Text = number_of_units * retail_price
End If
End If
End If
End If
End If
End If
End If
End If
End Sub
http://i289.photobucket.com/albums/ll221/jiggyghallam/Customer.jpg
The problem i have is that certain values just don't work, ie
52 and pressing calculate just doesn't bring up anything (doesn't work)
4 works for wholesaler but not for retailer
3 works with both
21 works with both
18 works with wholesaler but not for retailer
what is the problem? how can i fix it? how can i make it so it doesnt have so many if statements?
any more questions please ask ;)
im using VB 6
im so confused i know my code is messed up there are to many ifs and i cant simplify it any help would be greatly appreciated :D :rolleyes:
knock knock Paul Komski ;)
~George :D
The shipshape packing company wants a program for their orders department to calculate and display the price of an order. The order clerks enter the number of units ordered, weather a customer is a wholesaler or a retailer, weather or not the customer is a special customer. Use a variety of controls for this data entry. The price the customer pays per unit depends on these three things the prices are
for wholesaler
1-5 units = $50
6-10 units = $45
11-20 units = $40
21-50 units = $35
over 50 units = $30
for retailers
1-3 units = $60
4-8 units = $55
9-15 units = $50
16-40 units = $45
over 40 units = $40
special customers get a discount of 10%
now i have a problem here is my code so far and the design
Option Explicit
Dim number_of_units As Integer
Dim whole_sale_price As Single
Dim retail_price As Single
Dim total As Single
Dim specail As Single
Private Sub cmdcalc_Click()
number_of_units = txtunits.Text
If number_of_units <= 5 Then
If optwhole.Value = True Then
whole_sale_price = 50
txttotal.Text = number_of_units * whole_sale_price
Else
If number_of_units <= 3 Then
If optretail.Value = True Then
retail_price = 60
txttotal.Text = number_of_units * retail_price
End If
End If
End If
Else
If number_of_units <= 10 Then
If optwhole.Value = True Then
whole_sale_price = 45
txttotal.Text = number_of_units * whole_sale_price
Else
If number_of_units <= 8 Then
If optretail.Value = True Then
retail_price = 55
txttotal.Text = number_of_units * retail_price
End If
End If
End If
Else
If number_of_units <= 20 Then
If optwhole.Value = True Then
whole_sale_price = 40
txttotal.Text = number_of_units * whole_sale_price
Else
If number_of_units <= 15 Then
If optretail.Value = True Then
retail_price = 50
txttotal.Text = number_of_units * retail_price
End If
End If
End If
Else
If number_of_units <= 50 Then
If optwhole.Value = True Then
whole_sale_price = 35
txttotal.Text = number_of_units * whole_sale_price
Else
If number_of_units <= 40 Then
If optretail.Value = True Then
retail_price = 45
txttotal.Text = number_of_units * retail_price
End If
End If
End If
If number_of_units > 50 Then
If optwhole.Value = True Then
whole_sale_price = 30
txttotal.Text = number_of_units * whole_sale_price
Else
If number_of_units > 40 Then
If optretail.Value = True Then
retail_price = 40
txttotal.Text = number_of_units * retail_price
End If
End If
End If
End If
End If
End If
End If
End If
End Sub
http://i289.photobucket.com/albums/ll221/jiggyghallam/Customer.jpg
The problem i have is that certain values just don't work, ie
52 and pressing calculate just doesn't bring up anything (doesn't work)
4 works for wholesaler but not for retailer
3 works with both
21 works with both
18 works with wholesaler but not for retailer
what is the problem? how can i fix it? how can i make it so it doesnt have so many if statements?
any more questions please ask ;)
im using VB 6
im so confused i know my code is messed up there are to many ifs and i cant simplify it any help would be greatly appreciated :D :rolleyes:
knock knock Paul Komski ;)
~George :D