Attribute VB_Name = "lib_increment" '------------------------------------------------------------------------------- 'File : lib_increment.bas ' Copyright mpl by ERB software ' All rights reserved ' http://wiki.yaslaw.info/dokuwiki/doku.php/vba/ 'Environment : VBA 2007 + 'Version : 1.0.0 'Name : lib_increment 'Author : Stefan Erb (ERS) 'History : 25.11.2014 - ERS - Creation '------------------------------------------------------------------------------- Option Explicit Public Enum incType itPreIncrement '++1 itPostIncrement 'i++ itPreDecrement '--i itPostDecrement 'i-- End Enum '/** ' * @param Number ' * @param incType Type der Encrementation. Default ist i++ ' * @retrun Number '*/ Public Function inc(ByRef i As Variant, Optional ByVal iIncType As incType = itPreIncrement) As Variant Select Case iIncType Case itPreIncrement: inc = preInc(i) '++i Case itPostIncrement: inc = postInc(i) 'i++ Case itPreDecrement: inc = preDec(i) '--i Case itPostDecrement: inc = postDec(i) 'i-- End Select End Function '/** ' * PreIncrement ++i ' * Zählt i eins hoch und gibt den Wert zurück ' * @param Number ' * @retrun Number '*/ Public Function preInc(ByRef i As Variant) As Variant i = i + 1 preInc = i End Function '/** ' * PostIncrement i++ ' * Gibt den Wert zurück und zählt dann i eins hoch ' * @param Number ' * @retrun Number '*/ Public Function postInc(ByRef i As Variant) As Variant postInc = i i = i + 1 End Function '/** ' * PreDecrement --i ' * Zählt i eins hoch und gibt den Wert zurück ' * @param Number ' * @retrun Number '*/ Public Function preDec(ByRef i As Variant) As Variant i = i - 1 preDec = i End Function '/** ' * PostDecrement i-- ' * Gibt den Wert zurück und zählt dann i eins hoch ' * @param Number ' * @retrun Number '*/ Public Function postDec(ByRef i As Variant) As Variant postDec = i i = i - 1 End Function