Format Number

# Thread: Format Number

1. Junior Member
Join Date
Dec 1969
Posts
28

## Format Number

How can I format a number to get 3 digits???<BR><BR>I use a random function and I get the random number but now I want to convert that number to a 3 digits number<BR>How can I format that result to get :<BR>Eg: For 12 I want to get 012<BR> For 6 I want to get 006<BR><BR>Thankx

2. Senior Member
Join Date
Dec 1969
Posts
16,931

## RE: Format Number

Function FormatNumber(strNumberToFormat, intNumberOfPlaces)<BR> if IsNumeric(intNumberOfPlaces) = False then<BR> Exit Function<BR> end if<BR> if Len(strNumberToFormat) &#062;= CInt(intNumberOfPlaces) then<BR> FormatNumber = strNumberToFormat<BR> end if<BR> while Len(strNumberToFormat) &#060; CInt(intNumberOfPlaces)<BR> strNumberToFormat = "0" & strNumberToFormat<BR> wend<BR> FormatNumber = strNumberToFormat<BR>End Function<BR><BR>Craig...

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•