输入Const下的百分比

时间:2013-08-22 14:44:02

标签: vb.net visual-studio

我应该怎么做呢? Const cdecTax As Decimal = 7.75%我试过把它放在小数形式(0.0775)并尝试舍入它,但舍入不起作用!

Private Sub lblFinalCostResponse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblFinalCostResponse.Click

    intFinalPrice = Format(Round, "0.00")

End Sub

1 个答案:

答案 0 :(得分:0)

由于您没有真正发布足够的代码,因此有点难以给您一个确切的答案。但是我假设您想要计算销售税并返回商品的最终价格,所以我认为这样的事情应该这样做:

Private Sub Button18_Click(sender As Object, e As EventArgs) Handles Button18.Click
    Debug.WriteLine(CalculateFinalPrice(CDec(13.3445)))
End Sub

Private Const cdecTax As Decimal = 0.0775D
Public Shared Function CalculateFinalPrice(costPrice As Decimal) As Decimal
    Return costPrice + (costPrice * cdecTax)
End Function

Output:
14.37869875