|
Please give me some more detail or link to that article. 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
|
|
|
|
|
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)
{
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')
{
Input = Input.Remove(0, 1);
Output += "And ";
continue;
}
if (Input.Length % 3 != 2)
{
Output += ConvertChar(Input[0].ToString());
if (Input.Length % 3 == 0 && Input.Length > 2)
Output += "Hundred ";
else
Output += GetSegment(Input.Length / 3);
Input = Input.Remove(0, 1);
continue;
}
else
{
if (Input[0] == '1')
{
Output += ConvertChar(Input.Substring(0, 2));
}
else
{
Output += ConvertChar(Input[0] + "0");
Output += ConvertChar(Input[1].ToString());
}
Output += GetSegment(Input.Length / 3);
Input = Input.Remove(0, 2);
}
}
return Output;
}
private string GetSegment(int seg)
{
switch (seg)
{
case 1: { return "Thousand "; }
case 2: { return "Million "; }
case 3: { return "Billion "; }
case 4: { return "Trillion "; }
default: { return ""; }
}
}
private string ConvertChar(string ToConvert)
{
switch (ToConvert)
{
case "1": { return "One "; }
case "2": { return "Two "; }
case "3": { return "Three "; }
case "4": { return "Four "; }
case "5": { return "Five "; }
case "6": { return "Six "; }
case "7": { return "Seven "; }
case "8": { return "Eight "; }
case "9": { return "Nine "; }
case "10": { return "Ten "; }
case "11": { return "Eleven "; }
case "12": { return "Twelve "; }
case "13": { return "Thirteen "; }
case "14": { return "Fourteen "; }
case "15": { return "Fifteen "; }
case "16": { return "Sixteen "; }
case "17": { return "Seventeen "; }
case "18": { return "Eighteen "; }
case "19": { return "Nineteen "; }
case "20": { return "Twenty "; }
case "30": { return "Thirty "; }
case "40": { return "Fourty "; }
case "50": { return "Fifty "; }
case "60": { return "Sixty "; }
case "70": { return "Seventy "; }
case "80": { return "Eighty "; }
case "90": { return "Ninety "; }
default: { return ""; }
}
}
PS.
It took me about 35mins to write and test the code. It may need some adjustments, but it should give you a good start.
Regards
|
|
|
|
|
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
Syed Shahid Hussain
|
|
|
|
|
Hello
I'm always happy to help you .
See you soon on the forum.
Regards
|
|
|
|
|
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
|
|
|
|
|
Hi
I have a string in format "21.05.2004" pleas tell me how to convert it to DataTime format.All time i get InvalidDataException.Pleas help me if you can.
when i want to read something good just seat and type it
|
|
|
|
|
DateTime.Parse ???
Make sure the culture is set correctly for you date format also.
only two letters away from being an asset
|
|
|
|
|
How to change the culture ???
when i want to read something good just seat and type it
|
|
|
|
|
System.Globalization.CultureInfo culture = new System.Globaliztion.CultureInfo("ru-RU"); // Russian
DateTime dt = ConvertTo.DateTime("21.05.2004",culture);
msdn site
|
|
|
|
|
Supper thank's
when i want to read something good just seat and type it
|
|
|
|
|
The System.Guid.NewGuid( ) method seems to have returned duplicate GUIDs, two days in a roll.
Is it possible? Is there any related .NET (1.0 or 1.1) bug reported for this problem?
|
|
|
|
|
|
Hi,could you have code or link to code
For accessing Scheduled Task (windows) created by or modified by the Scheduled Task wizard.
|
|
|
|
|
I am developing windows application in .NET 1.1 using C#. I have developed a custom control for text editing in my application. Whenever i drop that control from toolbox to the form, it does not show the control on form on design time. When I run thaat form, it works pretty fine and it shows that control at run time. But at design time, the Visual Studio is not showing the control. What is the Problem that the control is not shoiwn at design time?
Thanks,
Sandeep S. Sekhon
|
|
|
|
|
If you have something in the design of the control that you do with some variable code then this occurs. For example you may be showing something that the control can only reach when the executable just runs. Something which can only have an appropriate value in runtime etc. Look for such things. You most probably have some code in control's initialize method.
|
|
|
|
|
But running the application for one time, I closed the Visual Studio. I again opened that same application, but this time the control was shown on the form.
Thanks,
Sandeep S. Sekhon
|
|
|
|
|
Hi,
My class looks like
public abstract class ShellApplicationBase<TModule, TModuleLoader> : BaseNet.Icarus.Shell.Interfaces.IShellApplication
{
}
Every class in my app should now be able to access the shell class. Therefore I wanted to implement a singleton where one could access Shell.Instance.DoNothingAndWaitInfite();
to do so i did
static IShellApplication _instance;
public IShellApplication Instance
{
get
{
return _instance;
}
}
so far so good, there is a static public IShellApplication Property on my shell class. Now one would have the idea to access this singelton inside the app
ShellApplicationBase<???>.Instance.DoNothingAndWaitInfite();
How can one access the generic class .Instance without knowing the concrete Types ( ??? ) that have been used to make a new instance of the generic class?
I just like to access this shell class from everywhere in my app, any ideas?
myMsg.BehindDaKeys = "Chris Richner";
|
|
|
|
|
You can code this way:
ShellApplicationBase<SomeConcretClassType>.GetInstance().DoNothingAndWaitInfite();
or
ShellApplicationBase<SomeConcretClassType> myInstance = ShellApplicationBase<SomeConcretClassType>.GetInstance();
myInstance.DoNothingAndWaitInfite();
Note that GetInstance() has been changed from Property to a public static method. I'm not sure about if you can use Property before any instance is constructed.
-- modified at 12:43 Friday 8th September, 2006
Best,
Jun
|
|
|
|
|
Hi Jun Du,
One have to know the SomeConcretClassType to access the class type to get the Instance property. What happens now if the class instance was made by
new ShellApplicationBase<ConcreteClassA>();
but one access the singleton inside the application as
ShellApplicationBase<ConcreteClassB>.Instance.DoNothingAndWaitInfite();
as far as I could see this is not the same but it would work, right? There must be a way to retrieve this Instance property on this generic class without giving types to access just the class type, am I wrong?
myMsg.BehindDaKeys = "Chris Richner";
|
|
|
|
|
Chris Richner wrote: One have to know the SomeConcretClassType to access the class type to get the Instance property.
Yes, that is what you used generic class for. If you don't or needn't know SomeConcretClassType, why do you use a generic class?
Chris Richner wrote: What happens now if the class instance was made by
new ShellApplicationBase();
No, you can't call Singleton's contructor directly. It's protected. You have to get the instance via static call GetInstance().
Chris Richner wrote: There must be a way to retrieve this Instance property on this generic class without giving types to access just the class type, am I wrong?
Give a try, but I never thought we could call any method of a generic class without defining a "concret" class first.
Best,
Jun
|
|
|
|
|
public class Test<t> { public static int member; }
Test<int>.member = 2;
Test<string>.member = 3;
Console.WriteLine(Test<int>.member); // outputs 2
Every specialisation of Test<t> will have it's own static fields, so you always need a concrete type. If you just want one instance for all Test<t>, you have to create another non-generic class to hold the field and property.
|
|
|
|