Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MESSAGEBOX Right Align Problem
Message
From
29/09/2005 09:00:07
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
MESSAGEBOX Right Align Problem
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01054437
Message ID:
01054437
Views:
61
I want to create a MESSAGEBOX that right-justifies numbers following a series of strings. Can somebody tell me why the following code doesn't work and perhaps suggest a better alternative?
lcString1 = 'State'
lcString2 = 'Federal'
lcString3 = 'State, transfer to Federal'

lcMessage = PadWidth(lcString1,'.',50) + TRANSFORM(1) + CHR(13) + ;
	    PadWidth(lcString2,'.',50) + TRANSFORM(2) + CHR(13) + ;
	    PadWidth(lcString3,'.',50) + TRANSFORM(3)
				
MESSAGEBOX(lcMessage,64,'My Message')

RETURN
*
*===================================================
*
FUNCTION PadWidth
*
LPARAMETERS tcString,tcPadChar,tnWidth,tcFontType 
*
LOCAL ;
	lcFont,;
	lnFontSize,;
	lcFontType,;
	lnPadCharWidth,;
	lnStringWidth,; 
	lnI,; 
	lcReturn
	
lcFontType = IIF(EMPTY(tcFontType),'N',tcFontType)
lcFont = WFONT(1)
lnFontSize = WFONT(2)
lnStringWidth = 0

FOR lnI = 1 TO LEN(tcString)
	lnStringWidth = lnStringWidth + TXTWIDTH(SUBSTR(tcString,lnI,1),lcFont,lnFontSize,lcFontType)
ENDFOR

IF lnStringWidth >= tnWidth
	lcReturn = tcString
ELSE
	lnPadCharWidth = TXTWIDTH(tcPadChar,lcFont,lnFontSize,lcFontType)
	lcReturn = tcString + REPLICATE(tcPadChar,ROUND((tnWidth - lnStringWidth)/lnPadCharWidth,0))
ENDIF 

RETURN lcReturn
*
*====================================================
* End:  PadWidth
*====================================================
Ray Roper
Next
Reply
Map
View

Click here to load this message in the networking platform