Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Instead of in Leading zeros show * instead of 0 in Reports and forms , Grids

Status
Not open for further replies.

mstrcmtr

Programmer
Nov 14, 2007
103
PK
Is there any way in numeric value instead of zeros show * sign in Reports , Forms , Grids Numeric Field type

e.g.

000000008756.00

instead

********8756.00
 
Thanks how can increase the Font size of **** using font size 12 for Numeric Field in Report but * size is smaller then numeric digits
 
You can't, without doing a lot of programming. Not a good idea, at least that's what I think. Maybe if you should try another font?
 
That's the way that most fonts are designed. The asterisk nearly always appears smaller than the letters and digits, and is usually set higher within the height of the characters. If you don't like that, look for a font where the asterisk is relatively large. Couier New would be a posibility.

The only other option that comes to mind is to split the field into two - one for the asterisks and one for the digits - and set each in a different font size. But obviously that would be difficult in this case.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Looking through the 172 fonts installed on my system, all of them have the asterisk smaller and higher than the letters and digits. The only exception is Gill Sans Ultrabold, where the asterisks take up the full height, but that would be entirely unsuitable for a report.

If this really is important for you, you'll just have to look for some other way of providing this feature.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
If that's really important you might get along with a font editor. You only need to work on the asterisk character. From the legal side it's perhaps a bit of an issue, also you'd need to set up a font with your application setup, just for that feature.

Why isn't right aligning enough?

Should this ensure defense against fraud, ie nobody should be able to add a leading non zero digit to a printed number, ie on a cheque?
Would another character solve the problem, too?

Bye, Olaf.
 
1) First, you can add the format *********.** to the field properties, to the Format page, in the Format expression textbox, without changing the field expression.

render0_tvrlqe.png


2) There is a complicated way to achieve what you are asking, but you must use two different fields and you must deal with SET REPORTBEHAVIOR 90.
Attached is a zip file containing a demo (a test prg and a test report)


First create a report variable named nNewPos

The first field must have the expression the asterisks, i.e
Code:
IIF(RAT("*",TRANSFORM(ii,"@R **********")) > 0, LEFT(TRANSFORM(ii,"@R **********"),RAT("*",TRANSFORM(ii,"@R **********"))), TRANSFORM(ii,"@R **********"))

and as Runtime extension code (When Render, see also the picture from below the code)

Code:
LPARAMETERS toFX, toListener, tcMethodToken,;
   tP1, tP2, tP3, tP4, tP5, tP6,;
   tP7, tP8, tP9, tP10, tP11, tP12

LOCAL lclc,tnPixels,tnPixels1,lnTwips,lcName,lnSize,lnFontSize
lnFontSize = 12 && the size used for asterisks. If you change the font size for this filed, change this value accordingly

IF RAT("*",TRANSFORM(ii,"@R **********")) > 0
	* Extract the asterisks
	lclc = TRANSFORM(ii,"@R **********")
	* Calculate the width of the asterisks in pixels
	lcName = _Screen.FontName && change the settings
	lnSize = _Screen.FontSize
	_Screen.FontName = "Courier New"  && use the field font name and size 
	_Screen.FontSize = m.lnFontSize
	tnPixels = _Screen.TextWidth(LEFT(m.lclc,RAT("*",m.lclc)+1)) && get the width of the asterisks in pixels
	tnPixels1 = _Screen.TextWidth(LEFT(m.lclc,RAT("*",m.lclc)))
	_Screen.FontName = m.lcName && restore the settings
	_Screen.FontSize = m.lnSize

	* Calculate the width of the asterisks in  1/960 inch (960 dpi)
	LOCAL lnDeviceHandle, lnPixelsPerInch, lnTwips
	* Declare the required API functions
	DECLARE INTEGER GetDC IN USER32 AS GetDC INTEGER hwnd
	DECLARE INTEGER ReleaseDC IN USER32 AS ReleaseDC ;
	  INTEGER hwnd, INTEGER hdc  
	DECLARE INTEGER GetDeviceCaps IN GDI32 AS GetDeviceCaps ;
	  INTEGER hdc, INTEGER nIndex

	* Get a handle to the current device
	lnDeviceHandle = GetDC(0)

	* Get pixels per inch for the device in the 
	* specified direction
	lnPixelsPerInch = ;
	  GetDeviceCaps(lnDeviceHandle, 88) && 88 width, 90 height

	* Release the handle
	lnDeviceHandle = ReleaseDC(0, lnDeviceHandle)

	CLEAR DLLS "GetCD", "ReleaseDC", "GetDeviceCaps"

	* Do the conversion
	lnTwips = CEILING(m.tnPixels * 960 / m.lnPixelsPerInch) && 1440

	* Change the with of the field to the newly calculated size
	tp4 = m.lnTwips + m.lnFontSize
	* Store the left position + the new width of this field into report variable nNewPos
	* nNewPos will become the new left position of the other field (the one with digits)
	* tP2 holds the left position and tP4 the width of the object. Both are passed by reference (can be changed)
	nNewPos = m.tP2 + CEILING(tnPixels1 * 960 / lnPixelsPerInch) + 10
ELSE && when are no asterisks
	nNewPos = m.tp2 && the other field will be placed over this one
	tp4 = 1 && and this one will be not printed. I cannot use Print When, because it must be rendered. Also I can not use 0. But 1 means 1/960 of a inch
ENDIF

render1_l6juyp.png


The second field must have as expression the digits, i.e
Code:
IIF(RAT("*",TRANSFORM(ii,"@R **********")) > 0, SUBSTR(TRANSFORM(ii,"@R **********"),RAT("*",TRANSFORM(ii,"@R **********"))+1), TRANSFORM(ii,"@R **********"))

and as Runtime extension code
(When Render, see also the picture from below the code)
Code:
tP2 = nNewPos && the newly left margin of the field
render2_ndqmbc.png


P.S.
Used some code from hexcentral.com

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania

 
numeric value

Keep in mind that if a value is shown with either leading Zeros or leading Asterisks, it is NOT a NUMERIC.
Instead it is a Character value displaying characters that appear as numbers.

It may have started as a Numeric value, but it was somehow changed (possibly for display purposes in Reports , Forms , Grids) to a Character and, as such, is no longer usable for mathematical calculations.

Good Luck,
JRB-Bldr



 
You may try the following

Modify your cursor to include 2 Char type fields
for example CNUMBER, CSTARS

then
replace all CNUMBER with alltrim(str(INUMBER))
replace all CSTARS with left("********************",15-len(alltrim(CNUMBER)) && Modify the len as required

in your report print both fields
CSTARS as right aligned, set your fonts as required.
CNUMBER as left aligned, set your fonts as you require.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top