User Tools

Site Tools


vba:cast:roundcurr

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
vba:cast:roundcurr [24.08.2016 09:28:16]
yaslaw
vba:cast:roundcurr [31.05.2017 11:01:17]
yaslaw [Code]
Line 15: Line 15:
  
 ===== Definition ===== ===== Definition =====
-<​code>​Double ​cValue(Double ​[,Double])</​code>​ +<​code>​roundedValue ​roundCurr(value, precision ​[,roundType])</​code>​ 
-<code vb>​roundCurr(ByVal iValue As Double, ByVal iPrecision As Double) As Double</​code>​+<code vb>​roundCurr(ByVal iValue As Double, ByVal iPrecision As Double, Optional ByVal iRoundType As rcRoundType = rcRound) As Double</​code>​
  
   ***iValue** Wert der gerundet werde soll   ***iValue** Wert der gerundet werde soll
   ***iPrecision** Genauigkeit. Achtung: Ist nicht die Anzahl Nachkommastellen. Auf ganze Zahlen Runden ist also nicht 0 sondern 1 (siehe Beispiele)   ***iPrecision** Genauigkeit. Achtung: Ist nicht die Anzahl Nachkommastellen. Auf ganze Zahlen Runden ist also nicht 0 sondern 1 (siehe Beispiele)
 +  ***iRoundType** Art wie gerundet werden soll. Siehe Enum rcRoundType
 +  ​
 +==== Enum rcRoundType ====
 +<code vb>'/​**
 +' * Type, wie die Funktion roundCurr() arbeiten soll. Normal runden, Aufrunden, Abrunden
 +' */
 +Public Enum rcRoundType
 +    rcRound ​    '​Normal runden ​                         roundCurr(3.6,​ 0.5) = 3.5
 +    rcHalfDown ​ 'Alias zu normal. 0.5 wird abgerundet ​  ​roundCurr(3.25,​ 0.5, rcHalfDown) = 3
 +    rcHalfUp ​   'Ab der Hälfte aufrunden ​               roundCurr(3.25,​ 0.5, rcHalfUp) = 3.5
 +    rcDowwn ​    '​immer abrunden ​                        ​roundCurr(3.4,​ 0.5, rcDowwn) = 3
 +    rcUp        'immer aufrunden ​                       roundCurr(3.1,​ 0.5, rcUp) = 3.5
 +End Enum</​code>​
  
 ==== Beispiele ==== ==== Beispiele ====
Line 45: Line 58:
 <​Double>​ 100 <​Double>​ 100
 </​code>​ </​code>​
 +
 +Auf/​Abrunden
 +<code vb>'​Normal runden ​                         ​
 +d roundCurr(3.6,​ 0.5) 
 +<​Double>​ 3.5
 +
 +'Alias zu normal. 0.5 wird abgerundet ​  
 +d roundCurr(3.25,​ 0.5, rcHalfDown) ​
 +<​Double>​ 3
 +
 +'Ab der Hälfte aufrunden ​               ​
 +d roundCurr(3.25,​ 0.5, rcHalfUp) ​
 +<​Double>​ 3.5
 +
 +'immer abrunden ​                        
 +d roundCurr(3.4,​ 0.5, rcDowwn) ​
 +<​Double>​ 3
 +
 +'immer aufrunden ​                       ​
 +d roundCurr(3.1,​ 0.5, rcUp) 
 +<​Double>​ 3.5</​code>​
  
 ===== Code ===== ===== Code =====
 +Code zum importieren. Wenn er mit C&P in ein neus Modul eingefügt wird, dann muss die Zeile ''​Attribute VB_Name = "​cast_roundCurr"''​ entfernt werden.
 +
 <source '​%%fpath%%/​%%fname%%'​ vb> <source '​%%fpath%%/​%%fname%%'​ vb>
  
  
vba/cast/roundcurr.txt · Last modified: 31.05.2017 11:32:34 by yaslaw