Digit To text Converter [modified]
-
I want the functionality of converting digits into text. Any one give me code example or an article about that. Example: 209 Two Hundred and Nine thanks "and Nader where are u i need u'r help" -- modified at 14:42 Friday 8th September, 2006
Syed Shahid Hussain
-
I want the functionality of converting digits into text. Any one give me code example or an article about that. Example: 209 Two Hundred and Nine thanks "and Nader where are u i need u'r help" -- modified at 14:42 Friday 8th September, 2006
Syed Shahid Hussain
Search this messageboard for 'eleventh' and'twelveth', there is a nice switch statement to deal with that, the rest will be easy.
**
xacc.ide-0.2.0.57 - now with C# 2.0 parser and seamless VS2005 solution support!
**
-
Search this messageboard for 'eleventh' and'twelveth', there is a nice switch statement to deal with that, the rest will be easy.
**
xacc.ide-0.2.0.57 - now with C# 2.0 parser and seamless VS2005 solution support!
**
Please give me some more detail or link to that article. Thanks
Syed Shahid Hussain
-
Search this messageboard for 'eleventh' and'twelveth', there is a nice switch statement to deal with that, the rest will be easy.
**
xacc.ide-0.2.0.57 - now with C# 2.0 parser and seamless VS2005 solution support!
**
tell me more friend. I am waiting.:( Please :((
leppie wrote:
Search this messageboard for 'eleventh' and'twelveth'
What do you mean by that :^) Thanks
Syed Shahid Hussain
-
tell me more friend. I am waiting.:( Please :((
leppie wrote:
Search this messageboard for 'eleventh' and'twelveth'
What do you mean by that :^) Thanks
Syed Shahid Hussain
Hello friend:)
Syed Shahid Hussain wrote:
I am waiting.
No need. I'm working on it, and I'll post the code when I'm finished. Already half the way.
Regards:rose:
-
I want the functionality of converting digits into text. Any one give me code example or an article about that. Example: 209 Two Hundred and Nine thanks "and Nader where are u i need u'r help" -- modified at 14:42 Friday 8th September, 2006
Syed Shahid Hussain
Hello friend. Here is your code. I hope you like it;). It consists of 3 methods. You call the ToLiteral() method and supply it with the string you want to parse. It will subsequently call the other two methods to retreive the literals and the segments names. Forgive me for the poor comment -never been good in commenting-. I included a button click even handler to show you how to test for output and how to use the ToLiteral() method.
private void TestButton\_Click(object sender, EventArgs e) { //Random numbers in a MessageBox to test output MessageBox.Show("4\\n" + ToLiterals("4")); MessageBox.Show("57\\n" + ToLiterals("57")); MessageBox.Show("209\\n" + ToLiterals("209")); MessageBox.Show("8734\\n" + ToLiterals("8734")); MessageBox.Show("24567\\n" + ToLiterals("24567")); MessageBox.Show("973654\\n" + ToLiterals("973654")); MessageBox.Show("2315736\\n" + ToLiterals("2315736")); MessageBox.Show("27065154\\n" + ToLiterals("27065154")); MessageBox.Show("827464876\\n" + ToLiterals("827464876")); MessageBox.Show("1675376283\\n" + ToLiterals("1675376283")); } private string ToLiterals(string Input) { String Output = ""; while (Input.Length > 0) { if (Input\[0\] == '0')//Ignore zeros { Input = Input.Remove(0, 1); Output += "And "; continue; } if (Input.Length % 3 != 2) { // We are at the Xs if our number is XYX,XYX,XYX // Either first, or third position in each segment. Output += ConvertChar(Input\[0\].ToString()); if (Input.Length % 3 == 0 && Input.Length > 2) //third position in a segment Output += "Hundred "; else Output += GetSegment(Input.Length / 3); //first position Input = Input.Remove(0, 1); continue; } else { //We are talking about first and second positions togerther :YXX,YXX,YXX if (Input\[0\] == '1') //Is it Xteen? ie. 11-19 { Output += ConvertChar(Input.Substring(0, 2));
-
Hello friend. Here is your code. I hope you like it;). It consists of 3 methods. You call the ToLiteral() method and supply it with the string you want to parse. It will subsequently call the other two methods to retreive the literals and the segments names. Forgive me for the poor comment -never been good in commenting-. I included a button click even handler to show you how to test for output and how to use the ToLiteral() method.
private void TestButton\_Click(object sender, EventArgs e) { //Random numbers in a MessageBox to test output MessageBox.Show("4\\n" + ToLiterals("4")); MessageBox.Show("57\\n" + ToLiterals("57")); MessageBox.Show("209\\n" + ToLiterals("209")); MessageBox.Show("8734\\n" + ToLiterals("8734")); MessageBox.Show("24567\\n" + ToLiterals("24567")); MessageBox.Show("973654\\n" + ToLiterals("973654")); MessageBox.Show("2315736\\n" + ToLiterals("2315736")); MessageBox.Show("27065154\\n" + ToLiterals("27065154")); MessageBox.Show("827464876\\n" + ToLiterals("827464876")); MessageBox.Show("1675376283\\n" + ToLiterals("1675376283")); } private string ToLiterals(string Input) { String Output = ""; while (Input.Length > 0) { if (Input\[0\] == '0')//Ignore zeros { Input = Input.Remove(0, 1); Output += "And "; continue; } if (Input.Length % 3 != 2) { // We are at the Xs if our number is XYX,XYX,XYX // Either first, or third position in each segment. Output += ConvertChar(Input\[0\].ToString()); if (Input.Length % 3 == 0 && Input.Length > 2) //third position in a segment Output += "Hundred "; else Output += GetSegment(Input.Length / 3); //first position Input = Input.Remove(0, 1); continue; } else { //We are talking about first and second positions togerther :YXX,YXX,YXX if (Input\[0\] == '1') //Is it Xteen? ie. 11-19 { Output += ConvertChar(Input.Substring(0, 2));
Hi So so thanks. I am so happy that you has given me the code and spend your time on me. I'll use it and send u feedback. Thank you very much. (I cant imagine that some people are kind enough that they spend their precious time for others. I really appreciate you. I dont have words to thank U. Its my heart sound. By heart thanks alot. And dont mind if u dont like my talks. I am a simple boy and dont let any thing close in my heart, I say it at the spot.) God Bless You. Keep messaging, Your friend :rose:
Syed Shahid Hussain
-
Hi So so thanks. I am so happy that you has given me the code and spend your time on me. I'll use it and send u feedback. Thank you very much. (I cant imagine that some people are kind enough that they spend their precious time for others. I really appreciate you. I dont have words to thank U. Its my heart sound. By heart thanks alot. And dont mind if u dont like my talks. I am a simple boy and dont let any thing close in my heart, I say it at the spot.) God Bless You. Keep messaging, Your friend :rose:
Syed Shahid Hussain
Hello I'm always happy to help you:-D. See you soon on the forum.
Regards:rose:
-
I want the functionality of converting digits into text. Any one give me code example or an article about that. Example: 209 Two Hundred and Nine thanks "and Nader where are u i need u'r help" -- modified at 14:42 Friday 8th September, 2006
Syed Shahid Hussain
Well a switch is a manual and less elegant way of doing this. A preferred way is having all the digit equivalents in a string table, and then having the conjuntion operators in another one, and a mapping list for mapping the info. I will try to post some code on it, using the neural approach that i did 6 years back.
Excelsior Arjun Bahree "By The Might of Mjolnir" I Came! I Coded! I Conquered!
-
Hello I'm always happy to help you:-D. See you soon on the forum.
Regards:rose:
Thanks friend, Your code is so logical and it took my two hrs. for understanding it. How your made the logic in just 35 min. You are a true programmer. The code meet all my requirements and I'll use it in my Data Base program "as it is" without any changing. So thanks and so nice of you. God Bless You "If u read this plz send me your e-mail address." Bye
Syed Shahid Hussain
-
Well a switch is a manual and less elegant way of doing this. A preferred way is having all the digit equivalents in a string table, and then having the conjuntion operators in another one, and a mapping list for mapping the info. I will try to post some code on it, using the neural approach that i did 6 years back.
Excelsior Arjun Bahree "By The Might of Mjolnir" I Came! I Coded! I Conquered!
If you find code send me.
Syed Shahid Hussain