I am using Writer for a price tag template.
I have three textboxes involved in the calculation.
Textbox "PCT" will display the value of the completed calculation.
Textbox "RET" is the retail price of an item. The user enters this information.
Textbox "DIS" is the discounted price of an item. The user enters this information.
The calculation is as follows:
PCT = RET - DIS / RET
I have looked throughout the forum but have not located any help with this.
Anybody willing to offer some advice or direction?
I am at ground zero with Basic and UNO.
Thank you
Streub
[Solved] Textbox calculations in Writer template
[Solved] Textbox calculations in Writer template
Last edited by streub on Wed Aug 30, 2017 8:03 pm, edited 1 time in total.
Streub
The more I learn from this forum, the more I get excited about using this strange application
The more I learn from this forum, the more I get excited about using this strange application
Re: textbox calculations in Writer template
Does it have to be a textbox, and/or controlled by a macro?
Tables in Writer have simple calculation abilities. You can do it in one table with 3 cells, or in 3 separate 1x1 "tables".
See attached file. If you need to position the tables freely, you can have them inside separate frames.
Tables in Writer have simple calculation abilities. You can do it in one table with 3 cells, or in 3 separate 1x1 "tables".
See attached file. If you need to position the tables freely, you can have them inside separate frames.
- Attachments
-
- tablecalculations.odt
- (9.38 KiB) Downloaded 205 times
Re: textbox calculations in Writer template
The use of tables is an excellent suggestion. I will attempt to use as you had suggested and will
inform you of the results.
Thank you
inform you of the results.
Thank you
Streub
The more I learn from this forum, the more I get excited about using this strange application
The more I learn from this forum, the more I get excited about using this strange application
Re: textbox calculations in Writer template
I did try your suggestion of using frames and tables. It performed as needed; however, this method will not allow me to set a tab order as a textbox object can. Good idea.
Thank you
Thank you
Streub
The more I learn from this forum, the more I get excited about using this strange application
The more I learn from this forum, the more I get excited about using this strange application
Re: textbox calculations iand textbox format
The code below will calculate the vales of two textboxes and enter the results into a third.
The textbox with the result needs to be formatted to a percentage via macro. I cannot recall
how to do that.
The textbox with the result needs to be formatted to a percentage via macro. I cannot recall
how to do that.
Code: Select all
REM ***** BASIC *****
Sub oPct
oDoc = ThisComponent
oDocView = oDoc.getCurrentController()
oForm = oDoc.drawpage.forms(0)
tbp = oForm.getbyname("tbp")
tbr = oForm.getbyname("tbr")
tbd = oForm.getbyname("tbd")
tbp.text = (tbr.value - tbd.value) / tbr.value
End Sub
Streub
The more I learn from this forum, the more I get excited about using this strange application
The more I learn from this forum, the more I get excited about using this strange application
Re: textbox calculations in Writer template
Alternatively you could create a string in percentage format - something like
Note: I don't use macros myself, so syntax for the concatenation operator may be wrong
Code: Select all
tbp.text = ((tbr.value - tbd.value) / tbr.value) * 100 & "%"
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers