Notes Tips - Tip #2

Notes Tips

Ever had to create a sequential numbering system and the requirements defined a prefix of 0’s? (00003433).

Below is a function I wrote to automate the number generation:

Function AddLeadingZeros(OriginalNum As String, TotalLength As Integer)
AddLeadingZeros = String(TotalLength - Len(OriginalNum),"0") & OriginalNum
End Function

The first parameter is the number you wish to use as the base before the prefix of 0’s. The second parameter is the total length you wish the number structure to be.

Eg.
MyNumber = AddLeadingZeros("55",10)

Will return 0000000055

One Response to Notes Tips - Tip #2

  1. Will Barrows :

    What’s wrong with Format( 10, String( 55, “0″) ) ?
    No need for function…

Leave a Reply

Please note: Comment moderation is in use and may delay your comment's debut.
There's no need to post your comment twice if you don't see it right away.


Light up the night!: Globally Recognized Avatars (or: gravatars) are how some people make those little icons appear next to their names in replies here. Get one of your own for free today and use it everywhere you go!