本文介绍了我的项目在VB 2008 Express Edition中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编码如下:

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


我必须设置销售折扣率的if n else条件,当我输入原始价格和数量时,原始价格变为零,一切都变成了,而且如果我设置的if条件不起作用


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

推荐答案

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


这篇关于我的项目在VB 2008 Express Edition中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 17:26