Solved

FoxPro Padding

Posted on 2013-10-31
5
557 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 42

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 42

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

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…
This article discusses how to implement server side field validation and display customized error messages to the client.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 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