Solved

FoxPro Padding

Posted on 2013-10-31
5
527 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Visual Fox Pro commands 15 39
Faxing a Report from Within Visual FoxPro 5 158
Close table 1 210
Controlling the ''Executing remote" message when using SQLEXEC() 5 106
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…
There are many Password Managers (PM) out there to choose from. PM's can help with your password habits and routines, but they should not be a crutch you rely on too heavily. I also have an article for company/enterprise PM's.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

912 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

16 Experts available now in Live!

Get 1:1 Help Now