Microsoft Office 2010 professional

hi Is it possible to get a macro to convert numbers to words format for Indian Rupees types?

ie.,,

Rs. 1,000 - to - Rupees One thousand only

Rs.10,000 - to- Rupees Tenthousand only

Rs.1,00,000-to - Rupees One lakh only

Rs.10,00,000-to- Rupees Ten lakhs only

Rs.1,00,00,000- to Rupees One crore only

Rs.10,00,00,000-to -Rupees Ten crores only!!

Hi, The answer is Yes a macro can do this conversion, but it's probably been done before.

Start with a Google search.

The work involved in doing this from scratch is not insignificant.

Regards

HI

Use the below C# Code to convert currency to word indian format.Regards

Athaf Hussain B

Xturion

public string IntegerToWords(long inputNum)

{

int dig1, dig2, dig3, level = 0, lasttwo, threeDigits;

string retval = "";

string x = "";

string[] ones ={

"Zero",

"One",

"Two",

"Three",

"Four",

"Five",

"Six",

"Seven",

"Eight",

"Nine",

"Ten",

"Eleven ",

"Twelve ",

"Thirteen ",

"Fourteen ",

"Fifteen ",

"Sixteen ",

"Seventeen ",

"Eighteen ",

"Nineteen "

};

string[] tens ={

" Zero ",

" Ten ",

" Twenty ",

" Thirty ",

" Forty ",

" Fifty ",

" Sixty ",

" Seventy ",

" Eighty ",

" Ninety "

};

string[] thou ={

"",

"Thousand",

"Lakh",

"Crore",

"Trillion",

"Quadrillion",

"Quintillion"

};

bool isNegative = false;

if (inputNum < 0)

{

isNegative = true;

inputNum *= -1;

}

if (inputNum == 0)

return ("Zero");string s = inputNum.ToString();

int i = 3;

while (s.Length > 0)

{

// Get the three rightmost characters

x = (s.Length < i) ? s : s.Substring(s.Length - i, i);// Separate the three digits

threeDigits = int.Parse(x);

lasttwo = threeDigits % 100;

dig1 = threeDigits / 100;

dig2 = lasttwo / 10;

dig3 = (threeDigits % 10);// append a "thousand" where appropriate

if (level > 0 && dig1 + dig2 + dig3 > 0)

{

retval = thou[level] + " " + retval;

retval = retval.Trim();

}

// check that the last two digits is not a zero

if (lasttwo > 0)

{

if (lasttwo < 20) // if less than 20, use "ones" only

retval = ones[lasttwo] + " " + retval;

else // otherwise, use both "tens" and "ones" array

if (ones[dig3].ToString() != "Zero")

{

retval = tens[dig2] + " " + ones[dig3] + " " + retval;

}

else

{

retval = tens[dig2] + " " + retval;

}

}

// if a hundreds part is there, translate it

if (dig1 > 0 && level == 0)

retval = ones[dig1] + " Hundred " + " and " + retval;

s = (s.Length - i) > 0 ? s.Substring(0, s.Length - i) : "";

level++;

i = 2;

}while (retval.IndexOf(" ") > 0)

retval = retval.Replace(" ", " ");retval = retval.Trim()+" only";

if (isNegative)

retval = "negative " + retval;return (retval);

}

Ask Your Question

Weekly Poll

Do you trust smart speakers to not spy on you?

Discuss in The Lounge

Poll History