Formatting numerical values for Web

View member feedback to this tip.

Here is a method for formatting numerical values in view columns on Web. The following method formats for maximum of 12 digits as 999,999,999,999 and you can change it as per your requirement.


amt:=@Text(999999999999);
length1:=@Length(amt);
amt1:=@If(length1=1;"";length1 
< 4; amt; length1< 5; 
@Middle(amt;0;1)+","+@Middle(amt;1;3);
length1< 6; @Middle(amt;0;2)+","+
@Middle(amt;2;3);length1< 7; 
@Middle(amt;0;3)+","+@Middle(amt;3;3);
length1< 8; @Middle(amt;0;1)+","+
@Middle(amt;1;3)+","+@Middle(amt;4;3);
length1< 9; @Middle(amt;0;2)+","+
@Middle(amt;2;3)+","+@Middle(amt;5;3);
length1< 10; @Middle(amt;0;3)+","+
@Middle(amt;3;3)+","+@Middle(amt;6;3);
length1< 11; @Middle(amt;0;1)+","+
@Middle(amt;1;3)+","+@Middle(amt;4;3)
+","+@Middle(amt;7;3);length1< 12; 
@Middle(amt;0;2)+","+@Middle(amt;2;3)
+","+@Middle(amt;5;3)+","+@Middle(amt;8;3);
length1< 13; @Middle(amt;0;3)+","+
@Middle(amt;3;3)+","+@Middle(amt;6;3)
+","+@Middle(amt;9;3);amt);
amt
 

MEMBER FEEDBACK TO THIS TIP

A far more flexible and effecient way of achieving the same result is: @Text(NumericField; ",")

-- Roger A.


Do you have comments of your own? Let us know.

This was first published in May 2003

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.