Solved

FoxPro Padding

Posted on 2013-10-31
5
513 Views
Last Modified: 2013-11-01
Good afternoon Experts!

OK, this seems simple, yet I'm stuck!
In my form I have a set of fields that I'm tring to create a column in the Details Section like this:

PADR('Company Name',18," ") + ':'
PADR('Company ID',18," ") + ':'
PADR('Company Code',18," ") + ':'

So that all my columns the : line up.

But they are not lining up?  Why?

Thanks,
Mark
0
Comment
Question by:smithmrk
  • 2
  • 2
5 Comments
 
LVL 16

Accepted Solution

by:
Kalpesh Chhatrala earned 500 total points
ID: 39614707
you need to modify code like below

PADR('Company Name',18," ") + ":"
PADR('Company ID',20," ") + ':'      && 2 Character is less so we need to add padding more
PADR('Company Code',18," ") + ':'

It's Font related Issue because each character width is not same in font like arial,Times New Roman,Verdana,Tahoma,etc.

if you use "Courier New" Font in your Label Caption then this problem will resolved.
0
 
LVL 41

Expert Comment

by:pcelba
ID: 39614712
You have to use non-proportional font, e.g. CourierNew to line up single texts.

Other options are:
1) Display the colon in separate column
2) Calculate the real text length using TXTWIDTH() and add variable number of spaces - this will not adjust all texts 100% accurately but possible deviation is about 1/3 of character.
0
 

Author Closing Comment

by:smithmrk
ID: 39614715
OK, Thanks!
0
 

Author Comment

by:smithmrk
ID: 39616541
I appreciate the additional comments pcelba, I had already given the points to kalpesh2804 before I saw your comment.

FYI...I changed the Font to Courier New...however I did like the idea of the TXTWIDTH(), which I may try when I find time, but for now it just seemed easier to change the font.

Thanks to BOTH of you!

Mark
0
 
LVL 41

Expert Comment

by:pcelba
ID: 39616560
It is OK, Kalpesh needs points more than me :-)

BTW, I would go the way of two separate fields. You may display left justified texts in one field/label and  colons in another field/label. It will be easy to design and independent on the text length.

TXTWIDTH() is useful if nothing else helps.

P.C.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
A procedure for exporting installed hotfix details of remote computers using powershell
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now