Friday, April 1, 2011

calculator in c#.net

Lesson 1
first Program is write Hello word

in c-sharp in advanced


This is our first program.We print Hello Word.So Lets Start .Press Alt+F11 OR Open visual studio.A window is open then click C# and in Bottom Click Windows Application .A Form is open. You can change the name of the form from Property Window.
You can create a text box from toolbox.then create a button it is also in tool box then add another text box in form.double click on  button and write this code

           private void button1_Click(object sender, EventArgs e)
        {
            string text = textBox1.Text;
            textBox2.Text = text;
        }



Lesson 2 

Dollar to Euro Conversion in c sharp and in vb.net

In video conversion is in vb.net but I tell you in c sharp.
Its simple.First of all put two textbox's on your form and one button
dafault  name of text box is textbox1 and textbox2
change the Text of your button "Convert to Euro"
double click on button then write this code

private void button1_Click(object sender, EventArgs e)
        {


            string dollars,euros;


            double dollar,euro;


            dollars = textBox1.Text;


            dollar = Convert.ToInt64(dollars);


            //  1 U.S. dollar = 0.702543206 Euros


            euro = dollar * 0.702543206;


            euros = euro.ToString();


            textBox2.Text = euros;

        }


 




Lesson 3
Make Calculator in c sharp.. But in video it is in vb.net
First of all put two text box's on Form and one button
double click on button and write this code

private void button1_Click(object sender, EventArgs e)
        {
            int no1 = Convert.ToInt16(textBox1.Text);     //   Enter value in first text box
            int no2 = Convert.ToInt16(textBox2.Text);    //    Enter value in second text box
            int sum = no1 + no2;                      //sum of two numbers
             textBox3.Text = sum.ToString();           // show value in textbox three

        }






Lesson 4

Print table in c sharp
first of all add a text box and a list box and a button
double click on button
write this code

 private void button1_Click(object sender, EventArgs e)
        {
            int answer;
            string lines;
            int number = Convert.ToInt16(textBox1.Text);
            for (int count = 1; count <= 10; count++)
            {
                answer = number * count;
                lines = count.ToString() +   "*"   +   number.ToString()   +   "="   +   answer.ToString();
                listBox1.Items.Add(lines);        //add answer in list box
            }