C#/c#

Advertisement


Question
QUESTION: its not proper it shud read 11 to 19. as 11 shud show eleven, 12 shud show twelove etc

ANSWER:  private void button1_Click(object sender, EventArgs e)
       {

         int i, j, counter = 0;
         label1.Text = "";
         if (textBox1.Text.IndexOf('.') > -1) //if it has floating point
         {
         String[] str = textBox1.Text.Split('.');
         for (j = 0; j < 2; j++)
         {
         if (j == 1)
         {
         label1.Text += " point ";
         counter = 0;

         }
         for (i = 0; i < str[j].Length; i++)
         {
         if (str[j].Length - counter != 2)
         switch (Convert.ToInt32(str[j][i].ToString()))
         {
         case 1:
         label1.Text += "one ";
         break;
         case 2:
         label1.Text += "two ";
         break;
         case 3:
         label1.Text += "three ";
         break;
         case 4:
         label1.Text += "four ";
         break;
         case 5:
         label1.Text += "five ";
         break;
         case 6:
         label1.Text += "six ";
         break;
         case 7:
         label1.Text += "seven ";
         break;
         case 8:
         label1.Text += "eight ";
         break;
         case 9:
         label1.Text += "nine ";
         break;

         }
         else
         {
         switch (Convert.ToInt32(str[j][i].ToString()))
         {
         case 1:
         switch (Convert.ToInt32(str[j][i + 1].ToString()))
         {
         case 0:
         label1.Text += "ten ";
         break;
         case 1:
         label1.Text += "eleven ";
         break;
         case 2:
         label1.Text += "twelve ";
         break;
         case 3:
         label1.Text += "Thirteen ";
         break;
         case 4:
         label1.Text += "forteen ";
         break;
         case 5:
         label1.Text += "fifteen ";
         break;
         case 6:
         label1.Text += "sixteen ";
         break;
         case 7:
         label1.Text += "seventeen ";
         break;
         case 8:
         label1.Text += "eighteen ";
         break;
         case 9:
         label1.Text += "nineteen ";
         break;
         }
         i++;
         break;
         
         case 2:
         label1.Text += "twenty ";
         break;
         case 3:
         label1.Text += "Thirty ";
         break;
         case 4:
         label1.Text += "fourthy ";
         break;
         case 5:
         label1.Text += "fifty ";
         break;
         case 6:
         label1.Text += "sixty ";
         break;
         case 7:
         label1.Text += "seventy ";
         break;
         case 8:
         label1.Text += "eighty ";
         break;
         case 9:
         label1.Text += "ninthy ";
         break;

         }
         }
         if(Convert.ToInt32(str[j][i].ToString())!=0)

         switch (str[j].Length - counter)
         {
         case 3:
         label1.Text += "hundred ";
         break;
         case 4:
         label1.Text += "Thousand ";
         break;
         case 5:
         label1.Text += " ten Thousand ";
         break;
         case 6:
         label1.Text += "hundred Thousand ";
         break;
         case 7:
         label1.Text += "million ";
         break;
         }
         counter++;
         }

         }
         }
         else
         {
         counter = 0;
         for (i = 0; i < textBox1.Text.Length; i++)
         {
         if (textBox1.Text.Length - counter != 2)
         switch (Convert.ToInt32(textBox1.Text[i].ToString()))
         {
         case 1:
         label1.Text += "one ";
         break;
         case 2:
         label1.Text += "two ";
         break;
         case 3:
         label1.Text += "three ";
         break;
         case 4:
         label1.Text += "four ";
         break;
         case 5:
         label1.Text += "five ";
         break;
         case 6:
         label1.Text += "six ";
         break;
         case 7:
         label1.Text += "seven ";
         break;
         case 8:
         label1.Text += "eight ";
         break;
         case 9:
         label1.Text += "nine ";
         break;

         }
         else
         {
         switch (Convert.ToInt32(textBox1.Text[i].ToString()))
         {
         case 1:
         switch (Convert.ToInt32(textBox1.Text[i+1].ToString()))
         {
         case 0:
         label1.Text += "ten ";
         break;
         case 1:
         label1.Text += "eleven ";
         break;
         case 2:
         label1.Text += "twelve ";
         break;
         case 3:
         label1.Text += "Thirteen ";
         break;
         case 4:
         label1.Text += "forteen ";
         break;
         case 5:
         label1.Text += "fifteen ";
         break;
         case 6:
         label1.Text += "sixteen ";
         break;
         case 7:
         label1.Text += "seventeen ";
         break;
         case 8:
         label1.Text += "eighteen ";
         break;
         case 9:
         label1.Text += "nineteen ";
         break;
         }
         i++;
         break;


         case 2:
         label1.Text += "twenty ";
         break;
         case 3:
         label1.Text += "Thirty ";
         break;
         case 4:
         label1.Text += "fourthy ";
         break;
         case 5:
         label1.Text += "fifty ";
         break;
         case 6:
         label1.Text += "sixty ";
         break;
         case 7:
         label1.Text += "seventy ";
         break;
         case 8:
         label1.Text += "eighty ";
         break;
         case 9:
         label1.Text += "ninthy ";
         break;

         }
         }
         if (Convert.ToInt32(textBox1.Text[i].ToString()) != 0)

         switch (textBox1.Text.Length - counter)
         {
         case 3:
         label1.Text += "hundred ";
         break;
         case 4:
         label1.Text += "Thousand ";
         break;
         case 5:
         label1.Text += " ten Thousand ";
         break;
         case 6:
         label1.Text += "hundred Thousand ";
         break;
         case 7:
         label1.Text += "million ";
         break;
         }
         counter++;
         }


         }



       }

---------- FOLLOW-UP ----------

QUESTION: hiiiii
i wana make calculater.
Explanation is in one multiline text box user enter the value like : 1+5+6+2+1 then ans shud 15 and if 15-2 ans shud 13 and if 15/5 then 3
so and so

ANSWER: the simplest way is as follow, there's other way too such as detecting each character and parsing them or when the user click on each number detect keys and do the action but I think the following code is the simplest one.
right click on your project in solution explorer , choose add reference , choose COM tab and then there search microsoft script control 1.0 and when you find it , click add

then in your form add a button which I named it button1 and a textbox which I named it textBox1
in your button click write the following code
private void button1_Click(object sender, EventArgs e)
       {

         MSScriptControl.ScriptControl sc = new MSScriptControl.ScriptControl();
         sc.Language = "VBScript";
         object result = sc.Eval(textBox1.Text);
         MessageBox.Show(result.ToString());



       }
so in your textbox you can enter simple equation , you don't need to add "=" for that and then click on your button to show you the result.
good luck

---------- FOLLOW-UP ----------

QUESTION: Thank you for reply, n program run successfully
bt i want tht value shud remain in textbox
Example. output shud like
1>1+2+3+4
>10
2>8/4+2
>4
ok
now can u explain that why we use msscript control
and language VB script in that
n u said thr is many other ways
thn can we made it without msscriptcontrol
if yes thn plz do so.......

Answer
Hello,
sorry for my late response. I was so busy with many projects.
we use script languages because C# or .net does not have such a capability , I mean in script languages someone wrote Eval function which do that but in C# or vb we should code that for instance we should code a function which use postfix or prefix method to calculate it, I mean for that you need to write 30 line code just to do what I mentioned in last message, so it is easier to use script languages. also script languages now adays are so popular I mean all programmers try to use it somehow in their code as you can see ajax based websites.
I will revise this answer when I go home to write that part for you.  

C#

All Answers


Answers by Expert:


Ask Experts

Volunteer


Hosnieh [Sara]

Expertise

Questions which I can answers: 1- Programming (C#.net, Vb.net, javascript, HTML) more Web applications 2- CSS 3-Databases (Ms SQL server -all versions) 4-OS (workstation and servers (windows)) 5- MS office 6- General problems in computer software I cannot answer other kinds of questions which I did not mention here.

Experience

my CV: http://iran-americamarket.com/Contact.aspx I have more than 8 years Experience in IT field. my core skills are : • Asp.net Developer (Portal, Dynamic websites ,e-commercial websites) • Visual studio.net 2003,2005,2008 (VB.net , C#.net , AJAX.net) • O.O programming (n-tier Architecture) • Database (SQL server 2000-2005, Oracle9i, Ms Access) , TSQL, Stored procedures, Triggers • IIS 5-6 , SSL (Installation and configuration SSL) , Network(TCP/IP ,Active directory , DHCP, … ), Windows 2000-2003 Server Configuration and administration • UML (usecase diagram, class diagram) , Microsoft Project • Graphics Design( Photoshop , Flash ) • JavaScript , CSS, DHTML, XML • Hardware (physical installation, configuration , and driver installation) • Ms Office all versions (Ms word, Ms Access, Ms Excel, Ms Outlook , Ms FrontPage, and etc) • OS (Windows –Linux) and VMware • Network Monitoring (Solarwinds) • Computer Teacher, English Teacher • MATLAB (simulations and computation projects)

Organizations
-

Publications
Translation Experience English to Farsi • Use brain scan to predict when people will buy products . May 2008 (Published in AI Magazine) – Medicine , AI • Totally tubular motors _Tomorrow automation technology : March 2008 (Published in AI Magazine) – AI , Mechanic, Industry • Improving PLC compatibility and function flexibility: March 2008 (Published in AI Magazine) – AI , Robotics , Industry • Make packaging lines more flexible: January 2008 (Published in AI Magazine) – AI , Robotics , Industry • Personal CNC : December 2007 (Published in AI Magazine) – AI , Medical , Industry • Multipurpose optical tools Characterize as MEMS: December 2007 (Published in AI Magazine)- optical physics • Managing Innovation: November 2007 (Published in AI Magazine) – IT Management • Calculating the total value of ownership (TVO):October 2007 (Published in San-ate Hooshmand Magazine) -IT and Economics

Education/Credentials
I am currently student and doing my Master in Computer Network Engineering

Awards and Honors
- Poster about new methods of management in Organization( Entrepreneurship ) - 2007

Past/Present Clients
-

©2012 About.com, a part of The New York Times Company. All rights reserved.