totalPrice를 계산하고 totalPriceOutputLabel에 반환하는 함수가 있습니다. 내 문제는 출력 형식을 "1,222"로 형식화해야합니다. 나는 그걸로 변환하는 방법을 알고있다.Visual Basic에서 통화 형식으로 문자열 변환
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
* * calculateButton_Click * 및 * totalPrice *가 (서식 제외) 동일한 작업을 수행하는 이유는 무엇입니까? 편집하는 동안 오류가 발생 했습니까? (* totalPrice * 함수는 현재 totalPrice *를 호출합니다.) – Chris
내 실수였습니다. 원래 게시를 업데이트했습니다. 감사합니다 – user1695704
잘 했어. 고맙습니다. – user1695704