Click here to Skip to main content
15,907,326 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
here is the Coding:
VB
Dim SalesDiscRate As Single, QuantityPurchased As Single, OriginalPrice As Single, DiscSalesTotal As Single, SalesPricePerItem As Single, SalesTaxDue As Single, TotalAmtDue As Single
   Private Sub btnCalculateSales_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculateSales.Click
       txtOrigPricePerItem.Text = OriginalPrice
       OriginalPrice = FormatCurrency(txtOrigPricePerItem.Text)
       txtQuantityPurchased.Text = Val(txtQuantityPurchased.Text)
       txtDiscountedSalesTotal.Text = DiscSalesTotal
       DiscSalesTotal = FormatCurrency(txtDiscountedSalesTotal.Text)
       txtSalesPricePerItem.Text = SalesPricePerItem
       SalesPricePerItem = FormatCurrency(txtSalesPricePerItem.Text)
       txtSalesTaxDue.Text = SalesTaxDue
       SalesTaxDue = FormatCurrency(txtSalesTaxDue.Text)
       txtTotalAmtDue.Text = TotalAmtDue
       TotalAmtDue = FormatCurrency(txtTotalAmtDue.Text)
       txtSalesDiscRate.Text = SalesDiscRate
       txtSalesDiscRate.Text = FormatPercent((SalesDiscRate) / 100)
       If QuantityPurchased >= 1 <= 10 Then
           SalesDiscRate = 5%
       End If
       If QuantityPurchased >= 11 <= 20 Then
           SalesDiscRate = 10%
       Else
           If QuantityPurchased >= 21 Then
               SalesDiscRate = 15%
           End If
       End If
       SalesPricePerItem = OriginalPrice * ((100 - SalesDiscRate) / 100)
       DiscSalesTotal = CSng(SalesPricePerItem) * CSng(QuantityPurchased)
       SalesTaxDue = CSng(DiscSalesTotal) * (7 / 100)
       TotalAmtDue = CSng(DiscSalesTotal) + CSng(SalesTaxDue)

   End Sub

I have to set the if n else condition for sales discount rate, when I input the the original price and quantity, the Original price goes to zero and everything becomes and also the if condition I set is not working
Posted
Updated 23-Feb-11 14:20pm
v3
Comments
Henry Minute 23-Feb-11 20:21pm    
Please ignore my previous message.

I have just spotted your explanation included in the code.

I have edited it so that it is outside the code block. :)

1 solution

I would start with the If Then block...

I am not familiar with VB but I am just trying to help

VB
If QuantityPurchased >= 1 And QuantityPurchased <= 10 Then
    SalesDiscRate = 5%
End If
If QuantityPurchased >= 11 And QuantityPurchased <= 20 Then
    SalesDiscRate = 10%
Else
    If QuantityPurchased >= 21 Then
        SalesDiscRate = 15%
    End If
End If
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900