15,900,907 members
See more:
I have a problem,

I developed a sub report. everything is fine. now i want to display totals of amount in words. In normal report i wrote a function and pass a string parameter to report.
now how to pass parameter to sub report sub reports.. plz help me..
Posted
Updated 21-Jul-11 23:48pm
v2
lukeer 22-Jul-11 7:25am
What's a sub report? Anyhow connected to US Navy reconnaissance?

## Solution 1

If I understood you want to express the numerical value in words, as 101,01 to one hundred and one point zero one?

If so, this is language dependent. You can Google for many English implementations.

Here is one example:

C#
```public static string NumberToWords(int number)
{
if (number == 0)
return "zero";

if (number < 0)
return "minus " + NumberToWords(Math.Abs(number));

string words = "";

if ((number / 1000000) > 0)
{
words += NumberToWords(number / 1000000) + " million ";
number %= 1000000;
}

if ((number / 1000) > 0)
{
words += NumberToWords(number / 1000) + " thousand ";
number %= 1000;
}

if ((number / 100) > 0)
{
words += NumberToWords(number / 100) + " hundred ";
number %= 100;
}

if (number > 0)
{
if (words != "")
words += "and ";

var unitsMap = new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };
var tensMap = new[] { "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" };

if (number < 20)
words += unitsMap[number];
else
{
words += tensMap[number / 10];
if ((number % 10) > 0)
words += "-" + unitsMap[number % 10];
}
}

return words;
}```

Cheers!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 OriginalGriff 80 Pete O'Hanlon 40 Member 1408653 10 Rajesh Pandya 5 Sterling Stewart -6
 Pete O'Hanlon 1,490 OriginalGriff 1,132 Richard MacCutchan 325 Richard Deeming 300 Dave Kreskowiak 280

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900