Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Formatting negative numbers
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
01137018
Message ID:
01137027
Vues:
19
>Dear Sirs:
>
>I want to format negative numbers enclosing in parentheses in an accounting package. I print the numbers with the following instruction (supossing value = -120):
>
>transform(value, "@(R 999,999,999.99")
>
>the output will be:
>
>( 120.00)
>
>But i don't know how to display this in a textbox or in a grid using FORMAT and INPUTMASK properties.
>
>I appreciatte your kindly advice.
>
>Sincerely:
>

Edmundo,

You can display it without using FORMAT or INPUTMASK but using ControlSource as follows:
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


	**************************************************
*-- Form:         form1 
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   07/17/06 02:12:00 PM
*
DEFINE CLASS form1 AS form


	DataSession = 2
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"


	ADD OBJECT text1 AS textbox WITH ;
		Height = 23, ;
		Left = 22, ;
		Top = 11, ;
		Width = 165, ;
		Name = "Text1"


	ADD OBJECT grid1 AS grid WITH ;
		ColumnCount = 1, ;
		Height = 176, ;
		Left = 22, ;
		Panel = 1, ;
		Top = 44, ;
		Width = 165, ;
		Name = "Grid1", ;
		Column1.Width = 123, ;
		Column1.Name = "Column1"


	ADD OBJECT form1.grid1.column1.header1 AS header WITH ;
		Caption = "Header1", ;
		Name = "Header1"


	ADD OBJECT form1.grid1.column1.text1 AS textbox WITH ;
		BorderStyle = 0, ;
		Margin = 0, ;
		ForeColor = RGB(0,0,0), ;
		BackColor = RGB(255,255,255), ;
		Name = "Text1"


	PROCEDURE Init
		thisform.text1.ControlSource = [(transform(negative, "@(R 999,999,999.99"))]

		thisform.grid1.RecordSource = "tmp" + thisform.Name 
		thisform.grid1.column1.ControlSource = [(transform(negative, "@(R 999,999,999.99"))]
	ENDPROC


	PROCEDURE Load
		CREATE CURSOR ("tmp" +thisform.Name) ;
		 (negative N(8,2))
		 
		 FOR i = 1 TO 100
		 	INSERT INTO ("tmp" +thisform.Name) ;
		 		VALUES ((-1) * (RAND() + 1000))
		 NEXT 
	ENDPROC


	PROCEDURE grid1.AfterRowColChange
		LPARAMETERS nColIndex
		thisform.text1.Refresh()
	ENDPROC

ENDDEFINE
*
*-- EndDefine: form1
**************************************************
Dawa Tsering


"Do not let any unwholesome talk come out of your mouths,
but only what is helpful for building others up according to their needs,
that it may benefit those who listen."

- Ephesians 4:29-30 NIV

Dare to Question -- Care to Answer

Time is like water in a sponge, as long as you are willing you can always squeeze some.

--Lu Xun, Father of Modern Chinese Literature

Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform