Lpad & Rpad
am 05.12.2007 22:11:19 von roy
Hi All,
I have a application which reads from a dat file.I import this into
the database.While exporting this back I want to format the data so
that the alignment is proper.
I have the data in decimals which have to be padded with 0 either to
right or left depending on the digits.((totals to 13 digits)
For some the data is like 58049.859 which is to be padded to make it
as 58049.859000(totally 13 digits)
Some are like 49.859 which is then to be padded as 00049.859000 or
9.85 to be padded as 00009.8500000.
I hope you can understand what I am trying to do here.
As the data is inconsistent,I am not sure how to do this.
I am able to do the padding for a regular number(without decimals) but
confused to do the same for decimals.
Thanks for any help.
Roy
Re: Lpad & Rpad
am 05.12.2007 22:41:37 von Lye Fairfield
Roy wrote in news:3d80a555-1f00-4eb0-932f-
cdd58855ed72@y5g2000hsf.googlegroups.com:
> 49.859
Debug.Print Format(49.859, "0000000000.0000000000")
0000000049.8590000000
You could decide how many zeroes.
Re: Lpad & Rpad
am 05.12.2007 22:46:19 von arch
On Wed, 5 Dec 2007 13:11:19 -0800 (PST), Roy
wrote:
>Hi All,
>I have a application which reads from a dat file.I import this into
>the database.While exporting this back I want to format the data so
>that the alignment is proper.
>I have the data in decimals which have to be padded with 0 either to
>right or left depending on the digits.((totals to 13 digits)
>
>For some the data is like 58049.859 which is to be padded to make it
>as 58049.859000(totally 13 digits)
>Some are like 49.859 which is then to be padded as 00049.859000 or
>9.85 to be padded as 00009.8500000.
>I hope you can understand what I am trying to do here.
>As the data is inconsistent,I am not sure how to do this.
>I am able to do the padding for a regular number(without decimals) but
>confused to do the same for decimals.
>
>Thanks for any help.
>
>Roy
Above, you say 13 digits, but your examples are all 5.6 (11 digits).
Not sure which you want. Adjust the format string below to suit your
needs:
?format(49.859,"00000.0000000")
00049.8590000
?format(9.85,"00000.0000000")
00009.8500000
You didn't make it entirely clear what you want to do with the
formatted output. (report, form, write to file, ???). Store the data
as numeric then format the output as shown above, when needed.
HTH,
Arch
Re: Lpad & Rpad
am 06.12.2007 16:41:52 von roy
On Dec 5, 4:46 pm, Arch wrote:
> On Wed, 5 Dec 2007 13:11:19 -0800 (PST), Roy
> wrote:
>
>
>
>
>
> >Hi All,
> >I have a application which reads from a dat file.I import this into
> >the database.While exporting this back I want to format the data so
> >that the alignment is proper.
> >I have the data in decimals which have to be padded with 0 either to
> >right or left depending on the digits.((totals to 13 digits)
>
> >For some the data is like 58049.859 which is to be padded to make it
> >as 58049.859000(totally 13 digits)
> >Some are like 49.859 which is then to be padded as 00049.859000 or
> >9.85 to be padded as 00009.8500000.
> >I hope you can understand what I am trying to do here.
> >As the data is inconsistent,I am not sure how to do this.
> >I am able to do the padding for a regular number(without decimals) but
> >confused to do the same for decimals.
>
> >Thanks for any help.
>
> >Roy
>
> Above, you say 13 digits, but your examples are all 5.6 (11 digits).
> Not sure which you want. Adjust the format string below to suit your
> needs:
>
> ?format(49.859,"00000.0000000")
> 00049.8590000
>
> ?format(9.85,"00000.0000000")
> 00009.8500000
>
> You didn't make it entirely clear what you want to do with the
> formatted output. (report, form, write to file, ???). Store the data
> as numeric then format the output as shown above, when needed.
>
> HTH,
> Arch- Hide quoted text -
>
> - Show quoted text -
lyle and Arch,
Thanks for your solutions.This is to format and then write to a file.
Roy