Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
SDH SDH is offline
external usenet poster
 
Posts: 19
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
SDH SDH is offline
external usenet poster
 
Posts: 19
Default 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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MessageBox Assistant SDH Excel Programming 4 April 19th 07 01:20 AM
messagebox help jimE Excel Programming 3 November 3rd 06 07:49 PM
Anything wrong with Messagebox API? RB Smissaert Excel Programming 2 January 23rd 06 06:55 PM
Printing messagebox nc Excel Discussion (Misc queries) 1 March 22nd 05 02:49 PM
messagebox problem Sam Excel Programming 1 February 6th 05 05:32 PM


All times are GMT +1. The time now is 09:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"