Topic: Number to Words

Hi every One,
         Can any one tell me about how to add total in words? For example if total of a bill is 245/- then it should be shown in words 'two hundreds forty five only. How it will be in report?

Re: Number to Words

Hello unforgettable,

There is a built-in function in MVD called toWords.  There are quite a few threads with that search. Maybe this will help you get started.

"Energy and persistence conquer all things."

Re: Number to Words

Thank you JoshuA. Can you explain this function how to use it?

4 (edited by sparrow 2023-01-27 17:04:23)

Re: Number to Words

HI all


http://myvisualdatabase.com/forum/viewt … 888#p44888

OR

http://myvisualdatabase.com/forum/viewtopic.php?id=8088

Re: Number to Words

Hello Everyone,
Unforgettable:  attached is an example of converting the value to words within MVD and then using it in FastReport.  The script is for GBP currency but you just change that for whatever currency is relevant to you.
I believe there is also a 'towords' function that can be used directly in FastReport itself (where you can also specify a currency code) although I've never used it, which obviously is more data efficient than storing it in MVD.
Derek.

Post's attachments

Attachment icon towords in report.zip 338.53 kb, 183 downloads since 2023-01-27 

Re: Number to Words

Hi Derek


I slightly modified Derek's project for the ToWords function in FastReport.

Post's attachments

Attachment icon towords1.rar 295.12 kb, 239 downloads since 2023-01-27 

Re: Number to Words

hi derek,
          Thank to upload the useful project. Can you tell about 'replacestr' and 'fourty' 'forty'?

Re: Number to Words

Hi,
The basic 'toword' function converts a monetary value to words using USD (US dollars) as its default currency..
If you are in another country (and using England as an example), you would use 'replacestr' to replace the word 'dollars' with 'pounds', 'cents' with 'pence' and so on.
There are however, a couple of small errors (spelling mistakes) in the basic 'toword' function - so the word 'forty' displays incorrectly as 'fourty', the word 'twelve' displays incorrectly as 'twelwe'.  So in this case, the script is using
'replacestr' to correct the spelling.
More generally, it's possible to use 'replacestr' to, for example, translate MVD system messages that appear by default in English and you want them to show in your native language.
Regards,
Derek.

Re: Number to Words

Thank you derek to guide. One more question, if there is round figure no sub division of currency than?

Re: Number to Words

Hi Unforgettable,
Use the 'replacestr' function like you already do;  for example, if GBP is the currency, simply replace 'and 00 Pence' with ' ' (in other words, blank). 
Please see the attachment.
Derek.

Post's attachments

Attachment icon towords in report2.zip 338.64 kb, 180 downloads since 2023-01-30 

11 (edited by unforgettable 2023-01-30 14:27:54)

Re: Number to Words

Thank you derek that is what I want to know but and 00 appear. I dont need it. How do I  eliminate  it?

Re: Number to Words

What I suggested earlier should work unless you are doing something different.
However one thing you should note is that existing data will not display correctly until you edit and update each record.
If it's not that, attach your project otherwise it's difficult to see what else might be going on.
Derek.

Re: Number to Words

Hi derek,
            Infact I dont want to "and 00" to be appeared.

Re: Number to Words

Hello,
I have a calculated field (cf_grandtotal) which has a currency value. How can I convert this value to words that will appear in the report like "Total amount paid is ____" where the blank space will display the cf_grandtotal converted to words.
Regards,
Eyeman

Re: Number to Words

Hi Eyeman,
You can either convert the value to words within MVD and take the field into FastReport as text or use a similar function within FastReport to convert the value.
Attached is a version doing the conversion within MVD.
Derek.

Post's attachments

Attachment icon eyeman to words.zip 440.27 kb, 146 downloads since 2023-04-09 

Re: Number to Words

Hello Derek,
Thank you for the solution, which works perfectly as usual.
I understand that here to save the cf_grandvalue to words in the invoice table, I need to use the Save button Onclick event (Form2_Button1_OnClick). For any other Edit field, where the value is directly entered in the form, I can use OnChange event linked to the Edit field to convert the value to words in another Edit field in the form.
Also I understand the need for dbupdate on closure of Form2, and deletion of data in Form1. However, why is formfalse needed?
Regards,
Eyeman

Re: Number to Words

Hi Eyeman,
I have templates that I use when creating applications to speed things up and to save me having to re-do the same things over and over again;  the template for your 'towords' example uses the new 'visual styles' function.
So the reason for 'formfalse' is as follows:
1. 
It's just a personal choice but I don't like showing the menu bar in my applications (see screen1 in the attachment).
2.
If you are using 'visual styles', although you can get rid of the menu bar options by writing a bit of script, it still leaves an 'empty' menu bar which is just a waste of screen space and doesn't look very good (see screen2 in the attachment).
But remember - the menu bar only appears on the very first form of your application - none of the others forms.  So.......
3.
I make a 'false form' to be the first form of my application and in the script, immediately open the 'real' form and close 'formfalse'.  The user doesn't notice and now I've got  all of the form (without an empty 'menu bar') available (see screen3 in the attachment)
If you don't use 'visual styles' or if you actually want the menu bar, then none of the above is required.
Derek.

Post's attachments

Attachment icon eyeman falseform.zip 50.9 kb, 130 downloads since 2023-04-12 

Re: Number to Words

Hi Derek,


try   formfalse.menu := nil;

Re: Number to Words

Hi Sparrow,
This is excellent!  Much easier than using false forms.
Is there a list somewhere where you can read about these extra features like formN.menu := nil  - I've not been able to find any reference.
Thanks for your help,
Derek.

20 (edited by sparrow 2023-04-12 20:54:27)

Re: Number to Words

Looking through the forum MVD saw an example of assigning its menu items to the form menu (Form1.Menu ... ). Well, I decided to try.


P.S. But just found another example from Konstantin. But here is the reassignment of the menu to the second form.
http://myvisualdatabase.com/forum/viewt … 339#p31339


How useful it is to look through the forum)))

Re: Number to Words

It's better to use := nil .
Related to user access control.
User management forms can be accessed by calling directly. To the rest of the menu items either directly or through the buttons if necessary.
e.g. Form1.mniExportData.Click;

Re: Number to Words

Hi Sparrow,
Understood.  Thanks for the extra information.
Derek.

Re: Number to Words

Hello Derek,
You pointed that there is a method to convert number to words in the FastReport also. Can you please elaborate?
Regards,
Eyeman

Re: Number to Words

Hi Eyeman,
Have a look here - http://myvisualdatabase.com/forum/viewt … 739#p46739
This is the way of using 'towords' within FastReport that was written and uploaded by Sparrow.
You can find the code he wrote in the 'column footer' of the report as follows:

[ToWords(SUM(<Report."items.amount">),'usd',2)]

Derek

Re: Number to Words

Hello Derek,
Thank you and Sparrow. The code will be very useful.
Regards,
Eyeman