Normal Topic Format Subform Value $ with printstring. (Read 1381 times)
Renato Piacenti
Member
*
Offline


No personal text

Posts: 48
Location: Manaus - Amazonas - Brazil
Joined: Jun 20th, 2005
Format Subform Value $ with printstring.
Dec 20th, 2017 at 2:23pm
Print Post Print Post  
Hi,
In the code below the result extracted from a subform, the format of the money appears $ 1500,00. I'm trying to get this value at $ 1.500,00 and I'm not getting it. Anyone have any suggestions?

Line code I'm using Ex:
VSPrice1 = @FormFieldValue ("ORDER", "GLOSS", vSub)
VSPrice1 = @Decimals (VSPrice1,2)
PrintString (@Text ((9 - @len (VSPrice1)) 2, "") + VSPrice1, 1010, vYCor, 0, "Arial", 11,0)
Undecided
  

Renato Piacenti&&Manaus Amazonas Brazil&&Aqui a Floresta esta sendo preservada.&&Preserve a sua tamb�m.
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Format Subform Value $ with printstring.
Reply #1 - Dec 21st, 2017 at 7:45pm
Print Post Print Post  
Are you just trying to insert the period as the thousandths separator? and/or are you trying to do something with alignment with the @Text()?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Renato Piacenti
Member
*
Offline


No personal text

Posts: 48
Location: Manaus - Amazonas - Brazil
Joined: Jun 20th, 2005
Re: Format Subform Value $ with printstring.
Reply #2 - Dec 21st, 2017 at 8:47pm
Print Post Print Post  
Ray the Reaper wrote on Dec 21st, 2017 at 7:45pm:
Are you just trying to insert the period as the thousandths separator?


Are you just trying to insert the period as the thousandths separator? Yes
  

Renato Piacenti&&Manaus Amazonas Brazil&&Aqui a Floresta esta sendo preservada.&&Preserve a sua tamb�m.
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Format Subform Value $ with printstring.
Reply #3 - Dec 22nd, 2017 at 3:09pm
Print Post Print Post  
If you have a money element on the parent form that is formatted the way you want the data to be displayed you can use @AsFormattedByLE().

ex:
Code
Select All
VSPrice1 = @FormFieldValue ("ORDER", "GLOSS", vSub)
PrintString (@AsFormattedByLE(CurrencyElement, 0, VSPrice1), 1010, vYCor, 0, "Arial", 11,0) 



If you do not have a currency element on the parent form, then you can do something like this:

In Global Code:
Code
Select All
Function FormatMoney(vVal as Money) as String
Var vBack as String
Var vWhole as String
Var vFrac as String
Var vDub as Double
Var vNeg as Boolean
Var vTSep as Char
Var vDSep as Char
Var vCurSymb as Char

	//Modify these 3 lines to change the Thousands Separator, Decimal Separator, and Currency Symbol
	vTSep = "."
	vDSep = ","
	vCurSymb = "$"

	vNeg = 0

	If vVal < 0 Then
	{
		vNeg = 1
		vVal = @ABS(vVal)
	}

	vWhole = @Str(@Int(vVal))
	vFrac = @Str(@Frac(vVal)) + "00"
	While @Len(vWhole) > 3
	{
		vBack =  vTSep + @Right(vWhole, 3) + vBack
		vWhole = @Left(vWhole, @Len(vWhole) - 3)
	}
	vBack = vWhole + vBack

	If @Instr(vFrac, ".") > 0 Then
	{
		vDub = @ToNumber(vFrac)
		vFrac = @Str(@Decimals(@Round(vDub, 2), 2))
		vFrac = @Right(vFrac, 2)
	}
	vBack = vCurSymb + vBack + vDSep + @Left(vFrac, 2)

	If vNeg = 1 Then
	{
		vBack = "-" + vBack
	}

	Return vBack
End Function 



and then:

Code
Select All
VSPrice1 = @FormFieldValue ("ORDER", "GLOSS", vSub)
PrintString(FormatMoney(VSPrice1), 1010, vYCor, 0, "Arial", 11,0) 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Renato Piacenti
Member
*
Offline


No personal text

Posts: 48
Location: Manaus - Amazonas - Brazil
Joined: Jun 20th, 2005
Re: Format Subform Value $ with printstring.
Reply #4 - Dec 26th, 2017 at 4:20am
Print Post Print Post  
Thank you Ray,
The 2 solutions worked very well!
I chose the First one the best adapted to my need!

VSPrice1 = @FormFieldValue ("ORDER", "Gloss", vSub)
vPrice1 = @AsFormattedByLE (Gloss, 0, VSPrice1)
PrintString (vPrice1, 990, vYCor, 0, "Arial", 11,0)

Thank you so much!
  

Renato Piacenti&&Manaus Amazonas Brazil&&Aqui a Floresta esta sendo preservada.&&Preserve a sua tamb�m.
Back to top
 
IP Logged