formatting text to include leading 0's
Here is a pair of functions I use. The first is written to pad a numeric
"Value" with zeros so that it is 4 characters long. The second one actually
does the work. It is generic and can pad any value (numeric or string) using
any character (not just zero) to any length.
'---------------------
Function AddLeadingZeros(Value)
If Len(Value) < 4 And IsNumeric(Value) then
Value = Pad(Value, 4, 0)
End If
AddLeadingZeros = Value
End Function
'---------------------
Function Pad(Value, Width, Char)
Pad = Right(String(Width, CStr(Char)) & CStr(Value), Width)
End Function
Quote:
> Hello:
> Is there a way to format a text string similiar to VB's
> format$ function?. I would like to include leading zero's.
> I have looked at formatnumber and formatcurrency but I
> don't think they let me decide how many leading zeros to
> use.
> Les F