![]() |
messagebox help
I have the following code that calculates a total cost:
Private Sub CmdCost_Click() If Me.txtQuantity.Value < "" Then prod = Me.lboProduct.Value Pprice = Application.WorksheetFunction.Index(Range("Price") _ , Application.WorksheetFunction.Match(prod, Range("Product"), 0)) MsgBox Pprice * txtQuantity, vbOKOnly, "Total Cost" End If End Sub Currently the total cost appears in the message box, but is there anyway i can get the format of the cost to include a $ and if possible two decimal places. |
messagebox help
Private Sub CmdCost_Click() If Me.txtQuantity.Value < "" Then prod = Me.lboProduct.Value Pprice = Application.WorksheetFunction.Index(Range("Price") _ , Application.WorksheetFunction.Match(prod, Range("Product"), 0)) cost = Pprice * txtQuantity totCost = Format(cost, "$00,000.00") MsgBox totCost, vbOKOnly, "Total Cost" End If End Sub "SDH" wrote: I have the following code that calculates a total cost: Private Sub CmdCost_Click() If Me.txtQuantity.Value < "" Then prod = Me.lboProduct.Value Pprice = Application.WorksheetFunction.Index(Range("Price") _ , Application.WorksheetFunction.Match(prod, Range("Product"), 0)) MsgBox Pprice * txtQuantity, vbOKOnly, "Total Cost" End If End Sub Currently the total cost appears in the message box, but is there anyway i can get the format of the cost to include a $ and if possible two decimal places. |
messagebox help
thanks JLGWhiz, it works now, i changed the format to $##,###.## so that the
zeros that are not required don't show up. "JLGWhiz" wrote: Private Sub CmdCost_Click() If Me.txtQuantity.Value < "" Then prod = Me.lboProduct.Value Pprice = Application.WorksheetFunction.Index(Range("Price") _ , Application.WorksheetFunction.Match(prod, Range("Product"), 0)) cost = Pprice * txtQuantity totCost = Format(cost, "$00,000.00") MsgBox totCost, vbOKOnly, "Total Cost" End If End Sub "SDH" wrote: I have the following code that calculates a total cost: Private Sub CmdCost_Click() If Me.txtQuantity.Value < "" Then prod = Me.lboProduct.Value Pprice = Application.WorksheetFunction.Index(Range("Price") _ , Application.WorksheetFunction.Match(prod, Range("Product"), 0)) MsgBox Pprice * txtQuantity, vbOKOnly, "Total Cost" End If End Sub Currently the total cost appears in the message box, but is there anyway i can get the format of the cost to include a $ and if possible two decimal places. |
All times are GMT +1. The time now is 03:26 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com