By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,704 Members | 1,867 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,704 IT Pros & Developers. It's quick & easy.

Lpad & Rpad

P: n/a
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
Dec 5 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Roy <pr********@yahoo.comwrote in news:3d80a555-1f00-4eb0-932f-
cd**********@y5g2000hsf.googlegroups.com:
49.859
Debug.Print Format(49.859, "0000000000.0000000000")

0000000049.8590000000

You could decide how many zeroes.
Dec 5 '07 #2

P: n/a
On Wed, 5 Dec 2007 13:11:19 -0800 (PST), Roy <pr********@yahoo.com>
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
Dec 5 '07 #3

P: n/a
Roy
On Dec 5, 4:46 pm, Arch <send...@spam.netwrote:
On Wed, 5 Dec 2007 13:11:19 -0800 (PST), Roy <praish1...@yahoo.com>
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
Dec 6 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.