Hi
I have a number returned from a datsbase and I have to display it on a
page with leading zeros. IE if 4 is returned I have to display 0004.
I get type mismatch errors if I use format() and I can't get the leading
zeros with FormatNumber().
I need to do this with ASP because I have to send an email receipt of the
number in the correct format.
Any clues?
Andy Green
This came up recently. A simple function like this will do the trick:
Function LeadZeros(lNum, lPadLength)
' e.g. LeadZeros(12, 4) = "0012"
LeadZeros = CStr(lNum)
If Len(LeadZeros) < lPadLength Then
LeadZeros = String(lPadLength - Len(LeadZeros), "0") & LeadZeros
End If
End Function
HTH
Phil
> Hi
>
> I have a number returned from a datsbase and I have to display it on a
> page with leading zeros. IE if 4 is returned I have to display 0004.
>
> I get type mismatch errors if I use format() and I can't get the leading
> zeros with FormatNumber().
>
> I need to do this with ASP because I have to send an email receipt of
the
> number in the correct format.
>
> Any clues?
>
> Andy Green