我有一个计算 totalPrice 并将其返回到我的 totalPriceOutputLabel 的函数。我的问题是,我需要将输出格式化为例如“1,222”。我知道如何使用
ToString("C2")
但我不确定如何在我的函数调用中附加它。有任何想法吗?
Public Class tileLimitedForm
Private enteredLength, enteredWidth As Double
Private enteredPrice As Decimal
Public Function area(ByRef enteredLength As Double, ByRef enteredWidth As Double)
area = Val(enteredLength) * Val(enteredWidth)
End Function
Public Function totalPrice(ByRef enteredLength As Double, ByRef enteredWidth As Double)
totalPrice = Val(area(enteredLength, enteredWidth)) * Val(enteredPrice)
End Function
Private Sub calculateButton_Click(sender As Object, e As EventArgs) Handles calculateButton.Click
totalPriceOutputLabel.Text = totalPrice(area(enteredLength, enteredWidth),enteredPrice).ToString("C2")
End Sub