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?
CodePudding user response:
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;
CodePudding user response:
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;