PC Review


Reply
Thread Tools Rate Thread

Currency Calculation

 
 
=?Utf-8?B?TnlsZXg=?=
Guest
Posts: n/a
 
      27th May 2007
I have had so much success from this site that I am now feeling very
adventorous

Based on Purchase Price, Discount, Freight and MarkUp required I caluclate a
selling price - the field is "SalePrice" dim is as Currency

What I would like to be able to do is make the Selling price finish in
either a 0 or a 5

Tks

 
Reply With Quote
 
 
 
 
Steve Schapel
Guest
Posts: n/a
 
      27th May 2007
Nylex,

Here is an example of a function you can use to round a currency amount
to the nearest 5 cents.

Public Function RoundTo5(amnt)
Dim TotalCents As Integer
Dim RoundCents As Integer
TotalCents = (amnt - Fix(amnt)) * 100
If (TotalCents Mod 5) > 2 Then
RoundCents = 5
Else
RoundCents = 0
End If
RoundTo5 = Fix(amnt) + (((TotalCents \ 5) * 5) + RoundCents) / 100
End Function

--
Steve Schapel, Microsoft Access MVP

Nylex wrote:
> I have had so much success from this site that I am now feeling very
> adventorous
>
> Based on Purchase Price, Discount, Freight and MarkUp required I caluclate a
> selling price - the field is "SalePrice" dim is as Currency
>
> What I would like to be able to do is make the Selling price finish in
> either a 0 or a 5
>
> Tks
>

 
Reply With Quote
 
JK
Guest
Posts: n/a
 
      28th May 2007
Nylex/Steve,

This one will round to (the nearest of) any number:

+++++++
Public Function RoundPrice( _
origPrice As Double, _
Optional nRoundTo As Double = 0.05 _
) As Double

If nRoundTo = 0 Then
'No rounding
RoundPrice = origPrice
Else
RoundPrice = _
Round(origPrice / nRoundTo, 0) * nRoundTo
End If

End Function
+++++

Regards
Jacob


"Steve Schapel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
| Nylex,
|
| Here is an example of a function you can use to round a currency amount
| to the nearest 5 cents.
|
| Public Function RoundTo5(amnt)
| Dim TotalCents As Integer
| Dim RoundCents As Integer
| TotalCents = (amnt - Fix(amnt)) * 100
| If (TotalCents Mod 5) > 2 Then
| RoundCents = 5
| Else
| RoundCents = 0
| End If
| RoundTo5 = Fix(amnt) + (((TotalCents \ 5) * 5) + RoundCents) / 100
| End Function
|
| --
| Steve Schapel, Microsoft Access MVP
|
| Nylex wrote:
| > I have had so much success from this site that I am now feeling very
| > adventorous
| >
| > Based on Purchase Price, Discount, Freight and MarkUp required I
caluclate a
| > selling price - the field is "SalePrice" dim is as Currency
| >
| > What I would like to be able to do is make the Selling price finish in
| > either a 0 or a 5
| >
| > Tks
| >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add new currency Symbol in Format/Cell/Currency NOORZAD Microsoft Excel Misc 2 22nd Jun 2009 07:59 AM
Simple Calculation using the Currency Data Type Hank Microsoft Access 3 16th Apr 2009 10:42 PM
currency and time calculation Tia Microsoft Excel Worksheet Functions 1 24th Jun 2008 10:31 AM
Currency Datatype Really Good to Use For Non-currency Fields? tbl Microsoft Access Database Table Design 4 10th Jul 2006 02:58 PM
Faulty Currency Calculation Ian D. Microsoft Access Forms 3 25th Jul 2004 01:32 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:44 AM.