Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Anders Altberg
  Where is Anders Altberg?
 Uppsala
 Sweden
 Anders Altberg
 To: Brad SanMarie
  Where is Brad SanMarie?
 
 California - United States
 Brad SanMarie
 Tags
Subject: RE: display numbers with leading 0's in grid
Thread ID: 289242 Message ID: 289284 # Views: 38 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Grids
Date: Thursday, December 30, 2010 10:18:21 AM         
   


> > Hi,
> >
> > Just wondering if it's possible to display numeric values in a grid with leading zero's when the number is too short. For example the grid (and table) contains:
> >
> > 10
> > 200
> > 4010
> >
> > I would prefer to see in my form's grid:
> >
> > 0010
> > 0200
> > 4010
> >
> > This would be much easier to read.
> > Unfortinately I cannot use character fields for these values, only numeric values.
> >
> > Regards, Gerrit
>
> Dear Gerrit,
>
> How about using an expression as the column's controlsource?
>
> For example:
>
> grid.column1.controlsource = " (RIGHT('0000' + ALLTRIM(STR(recordfield)), 4))"
>
> Brad Sanmarie



There are special functions for the purpose of padding strings and numbers: PADL; PADR, PADC
PADL(number,length,'0')

-Anders

ENTIRE THREAD

display numbers with leading 0's in grid Posted by Gerrit Broekhuis @ 12/29/2010 9:49:11 PM
RE: display numbers with leading 0's in grid Posted by Koen Piller @ 12/29/2010 10:00:47 PM
RE: display numbers with leading 0's in grid Posted by Gerrit Broekhuis @ 12/30/2010 11:35:51 AM
RE: display numbers with leading 0's in grid Posted by Koen Piller @ 12/30/2010 3:00:07 PM
RE: display numbers with leading 0's in grid Posted by Brad SanMarie @ 12/29/2010 11:07:12 PM
RE: display numbers with leading 0's in grid Posted by Anders Altberg @ 12/30/2010 10:18:21 AM
RE: display numbers with leading 0's in grid Posted by Brad SanMarie @ 12/30/2010 3:58:10 PM
RE: display numbers with leading 0's in grid Posted by Tariq mehmood @ 12/30/2010 4:24:25 AM
RE: display numbers with leading 0's in grid Posted by Martin Krivka @ 12/30/2010 7:14:25 AM
RE: display numbers with leading 0's in grid Posted by Russell Hill @ 12/30/2010 8:47:26 AM