-5

I am trying to make a crystal report in which there is a requirement to convert number into words of each individual digit. For Example: Convert 1234 into One Two Three Four or Convert 56789 into Five Six Seven Eight Nine If anybody can help?

  • 4
    Create an array or dictionary of the words and use it to map the values. – juharr May 09 '22 at 14:36
  • 1
    there is no build in functionality in .NET if your question was heading that way... – Mong Zhu May 09 '22 at 14:37
  • You may also find this question useful: https://stackoverflow.com/questions/829174/is-there-an-easy-way-to-turn-an-int-into-an-array-of-ints-of-each-digit – radoslawik May 09 '22 at 14:47
  • possible duplicates https://stackoverflow.com/questions/554314/how-can-i-convert-an-integer-into-its-verbal-representation – iSR5 May 09 '22 at 14:57

2 Answers2

0

Try this:

Inputs: numbers = String contains numbers

string result = "";
foreach(char c in numbers) {
    switch(c) { //Add more cases
        case '0':
            result = result + "Zero";
            break;
        case 1:
            result = result + "One";
            break;
    }
}
return result;
MM4
  • 1
  • 3
0

Use a formula like this:

local numbervar YourNumber := 56789;
local stringvar YourNumberAsString := ToText(YourNumber, 0, "");
local numbervar NumberOfDigits := Len(YourNumberAsString);
local stringvar array Words := ["One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"];
local stringvar result;
local numbervar i;
For i := 1 to  NumberOfDigits do
result := result + Words[Val(YourNumberAsString[i])] + " ";
result;
MilletSoftware
  • 3,521
  • 2
  • 12
  • 15