Saturday, 15 December 2012

Simple clock using note pad

Create a clock using note pad:

                                                          Lets create a simple clock using note pad.

Step 1:

            Go to your Desk top , right click on desk top ,select New and then Select Text Document.

             This will open note pad.

     Step 2:

                    Type the following code in this note pad
                     
                       MsgBox Time

Step 3:

               Go to File Menu and click on save as 
                this will show a save file dialog save
                Name it Welcome.vbs or Clock.vbs
                and click on all files in save as type.
                Then Click on Save.

                 
                        Now double click on this file and run it 
               it will simple shows a message box telling time in 12 hours format. 

Feel free to contact me at any time for any type of question. 
Please type a comment for more information and questions.

computer startup sounds

My computer say Welcome to me:

                                                      In this tutorial we are going to create such an application that speaks to you and will say you welcome at the every start up of your computer using Note Pad.

Step 1:

            Go to your Desk top , right click on desk top ,select New and then Select Text Document.

             

     Step 2:

                   This will open a new Text Document.
In this Text Document type the following code.

dim b
set b = CreateObject("sapi.spvoice")
b.speak"Welcome Mr Shakir, Its Good to see you again"
b.speak"Time is"
b.speak Time

Explanation:
       
dim b :
           creates a new Variable 

Set b:
           Set is used to change the property of the variable.
           In this program we Created a new object for speech library.

b.speak " Text ":
                             is used to speak the text typed after b.speak


Step 3:

               Go to File Menu and click on save as 
                this will show a save file dialog save
                Name it Welcome.vbs
                and click on all files in save as type.
                Then Click on Save.

                 

Step 4:

              Now copy this file

Step 5:

              Navigate to C:\Documents and Settings\All Users\Start Menu\Programs\Startup (in Windows XP)
and to 
C:\Users\ {User-Name}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup (in Windows 8, Windows 7 and Windows Vista) 
if C: is your System drive. 

Step 6:

             paste this file in Startup folder.

Now when ever you run this application or restart your computer this will say welcome to you.
Best of Luck 
Kindly type a comment for any kind of question for suggestion.
Feel free to contact me at any time.







Text to Voice Application

Text to Voice Application :

                                                in this tutorial we will create a text to voice application by using System.Speech.Synthesis step by step

Step 1:

              Start a new Windows form application in C sharp

Step 2:


          

    Go to solution explorer Right-Click on References 


Step 3:

            Then Click on Add references 

Step 4:

            Now first Click on .Net Then Click on System.Speech
then hit OK

          

Now we have added a new reference named System.Speech

Step 5:

             Now double click on your form.
now add a new name space using System.Speech.Synthesis;

Step 6: 

              Now Come back to your form and add a text box and on buttton
set text box property to Multi-line

Step 7:

          Now set the form as you wish your form should look like

Step 8:

             Double Click on Button 1 to add some code to it

Step 9:

                Type the following code under  Button 1 

            SpeechSynthesizer voice = new SpeechSynthesizer();
            voice.Speak(textBox1.Text);


            Step 10:

                          Now Run your program and enjoy text to speech application.
                         Type text in text box and click on button 1. It will speak for you.
                          
                                 Feel free to contact me for any question.



Monday, 26 November 2012

Getting Free space on your hard Drive

Getting Free space on your hard Drive:
                                                         let's create a simple console application that out put free space of hard drive.
Step 1:
            Start a new console application in C sharp.
Step 2:
          Type the following code to get a drive char from user;
           Console.WriteLine("Please enter a Drive character : ");
            string a = Console.ReadLine();
Step 3:
          Type the following code to get the memory information;
System.IO.FileInfo f_info = new System.IO.FileInfo(a);


Step 4:
          Type the following code to get the Name of Drive;


System.IO.DriveInfo d_info = new System.IO.DriveInfo(f_info.FullName);



Step 5:
          Type the following code to get the available free space on Drive;


Console.WriteLine(d_info.AvailableFreeSpace.ToString());


Final Step:
                    Over all code is as bellow.


            Console.WriteLine("Enter andy Char:");
            string a = Console.ReadLine();
            System.IO.FileInfo f_info = new System.IO.FileInfo(a + ":");
            System.IO.DriveInfo d_info = new System.IO.DriveInfo(f_info.FullName);
            Console.WriteLine(d_info.Name);
            Console.WriteLine(d_info.AvailableFreeSpace.ToString());
            Console.ReadLine();

Thursday, 22 November 2012

How to get data from text boxes using C Sharp

How to get data from text boxes using C Sharp:

                                                                                                                            we can get data from text boxes using c sharp.But there is  some thing little tricky that we have to do.Text boxes only store data in form of text so it is needed to convert data into required for to use it. So let's see how to get and use data form text boxes in easy steps.
Step 1:
            Start a new Windows form Application project.
Step 2:
           Add tow text boxes and a button on your form.
          It should look like as shown.


Step 3 ( getting Strings): 
            If we want to get String or text form text boxes we do not have to convert it. It's already have the text form.
we have to just write the following code and its ready.
              string a = textBox1.Text;
            string b = textBox2.Text;

Step 4: 
             If we want to out print these strings we have to use the following code.
          
              MessageBox.Show(a + b);

               Our program should out put the following message box.


Step 5( getting integers):
                                            Now lets get some integers from the same text boxes and use them.
                                            But now there is really need of converting them into integer variables.

                                                to convert the strings to integers we have to use the following code.

               int x = int.Parse(a);
            int y = int.Parse(b);

 Step 6: 
              To out print them we are going using following code.

            MessageBox.Show(a +" "+ b);

Step 7 : 
           To convert string to floats we have to use the following block of code.

              float f = float.Parse(a);
            float g = float.Parse(b);

Step  8: 
             To convert string to double we have to use the following block of code.
          
            double d = double.Parse(a);
            double c = double.Parse(b);





Step 9: After converting them we can use them where ever we want to use them.

I have tried to give you the best and simple tutorial, however if you are still confused i will be pleased to answer your concerns :)
Addition In C Sharp:
                                   Lets see addition in detail in simple steps.
Step 1:
           Start a new Windows form application project. 
Step 2:
             Go to toolbox and  add a button on your form.
Step 3:
            Now double click on Button you added.
Step 4:
            Now Create 3 variables and assign them values as under.           
            int a = 10;
            int b = 20;
            int c = 0;
 Step 5:
            We want to add variable "a" in to variable "b" and save the result in c the addition syntax will
  c =  a + b;

Step 6:
           if  we want to add variable "a" , "b" and  variable " c " and save the result in d the addition syntax will:
                  int d = a b +  c
Step 7:
            Now lets add some floats and doubles.
Addition of float and double variables uses the same method and syntax as integers.  
            
            float num_1 = 10;
            float num_2 = 20;
            float num_3 = 0;

to add num_1 to num_2 and save answer in num_3 type the following code.

num_3 = num_1 + num_2;

to add num_1 to num_2 and num_3  save answer in num_4 type the following code.

float  num_4= num_1 + num_2 + num_3;
Step 8:
            Now lets add some  doubles  or float and integers.

In cause adding floats or doubles to integers the results should be save in double or float variable.

let see the example.
 double  n1=3.525;

int z =10;

double  m= z+ n1;


Step 9: lets out put via message box.

MessageBox.Show(z + " + " + n1 +" = "+m);

This will show a message box as shown 




Feel free to contact me at any time for any type of question regarding C sharp.



Float points and Doubles.

Float points and Doubles:

As we know integers are variables that contains whole numbers. They can not store numbers that contain point or decimal like 0.1  ,  5.8  , 5.0089  or 10.776012, These numbers are stored in floats or doubles

How to Create Float Double Variable:

                                                                            To create and float simple type float before the name of variable.  
For example:


float num_1 ;

To create and Double simple type Double before the name of variable.
For example.

Double num_2 ;

How to assign a value to Float Double Variable: 

                                                                    To assign a value to a float variable you need to type the name of float of double then " = " equal sign and then type the value in numbers and remember to place semi column  "  ;  " at the end.
For example.

num_1 = 10.23;
num_2=1.02356;

How to out put  a value from Float or Double Variable:

                                                                                                      To out put a value from a double or float  variable you simple need to write the following code 

Console.WriteLine( num_1 );
Console.WriteLine( num_2 );


How to use the value stored in  an Float or Double Variable:

                                                                                                           If you want to use the value of float or double take the following example.

     float num_3 = num_1 - num_2 ;

Console.WriteLine( num_3 );

Media Player Using C Sharp:


Media Player Using C Sharp:

Step 1:
           Open a new Windows form Application Project.
Step 2:
      Go to Toolbox and drag Menu Strip to your Form.


Step 3:
  Go to Tool box and Drag an Open File Dialog to your Form.

Step 4:
Click anywhere on toolbox and click Choose items…


Step 5:
           You will see Choose Toolbox Items  Dialog opened
            Click on COM Components.



Step 6:
          Select Windows Media player from the list and Click OK.



Step 7:
            Now Windows Media player has been added to your toolbox items.

Step 8:
            Search Windows Media Player in toolbox and drag it to your Form.
            



 

                  It should look like this.

Step 9:
             Give some text to your Menus as shown.

              Now double Click on Open.


Step 10:
             Now Type the following code under the open sub_menu.

            openFileDialog1.InitialDirectory = "C:";
            openFileDialog1.FileName = "";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                axWindowsMediaPlayer1.URL = openFileDialog1.FileName;
            }
            else
            {
                MessageBox.Show("Canceled", "Canceled");
            }

Step 11:
                     Now Run the Program.
Feel free to contact me at any time for any question regarding c Sharp.


    

Wednesday, 21 November 2012

How to Get System Sounds in C sharp:

How to Get System Sounds in C sharp:

There are several types of system sounds in Operating system.Today we are going to learn how to get them.
lets get started in simple steps.
Step 1:
           Start a new (Windows form Application)  project in C sharp.
Step 2:
           Add five buttons on your C sharp Form as shown below,
Step 3:
               Now double click on button 1 to give some code to it.
Step 4:
              Type the following code under button 1

        System.Media.SystemSounds.Hand.Play();

Step 5:
            Now double click on button 2 and give the following code to button 2.

      
            System.Media.SystemSounds.Beep.Play();

  Step 6:
            Now double click on button 3 and give the following code to button 3.  

               System.Media.SystemSounds.Asterisk.Play();

Step 7:
             Now double click on button 4 and give the following code to button 4.


              System.Media.SystemSounds.Question.Play();

 Step 8:
               Now double click on button 5 and give the following code to button 5.

              System.Media.SystemSounds.Exclamation.Play();



 Step 9:
               Finally  your program should look like this.




Now Run your program and enjoy.
feel free to contact me at any time for any type of question regarding C Sharp.

Integers in C Sharp

As we know variables can store text as well as numbers.There are many way to store numbers like numbers can be stored in Variables called Floats Doubles and Integers.In this lesson we are going to learn Integers in detail.

Integers in C Sharp:

                             Integers are whole numbers like 1,2,3 or 450 , 6809 they don't contain any dismal point. 
How to Create an Integer Variable:
To create an integer simply type ' int ' and then name of the variable for example if you want to create an integer variable  ' Age ' you need to type the following code  

int Age;

How to assign a value to an Integer Variable: 

                                                                    To assign a value to an integer you need to type the name of integer then " = " equal sign and then the value in whole numbers,For example if you want to assign  integer "Age" a value of  " 22 " you have to write code in the following way.

Age = 22;

How to out put  a value from an Integer Variable:

                                                                                                      To out put a value from an integer variable you simple need to write the following code 

Console.WriteLine( Age );

How to use the value stored in  an Integer Variable:

                                                                                                           If you want to use the value of integer            take the following example.

     int Age_of_Father = Age + 10;

Console.WriteLine( Age_of_Father );

Monday, 19 November 2012

How to comment in C Sharp

How to comment in C Sharp:

                                           In Computer Programming Comments are used to remember things and to make programming easy .One thing that makes comments unique is that these are not seen by compiler or not executed while program is running . You can comment in lines as well as in paragraphs. Line by line method or one line comment  uses the following syntax.

Step 1:

         Type two forward  slashes

Step 2:

           Then type what ever you want on this line.

Example: 


         //Creating tow string variables.


Or



Now if you want an paragraph of comments you have to use the following Syntax.

Step 1:

           Type on forward Slash and then type a Star  (  *  )

Step 2:

           Type a paragraph of comments

Step 3:

 Now time to close the paragraph of Comments..
 type star (*) and then forward slash.
Now in this way you can close the paragraph

Example:




An other way to comment is to use comment button .
Select the line you want to convert in to comment and then press comment button as shown. 



Concatenation

Concatenation in c sharp:

Joining of things together in programming is said to be concatenation. It includes joining of two or more variables to make a long string. Lets take an example.


      private void button1_Click(object sender, EventArgs e)
        {
            //Creating two string variables.

            string First_Name;                      
            string Second_Name;           
            string Name;
         
            // Assigning values to Variables.

            First_Name= textBox1.Text;                    
            Second_Name = textBox2.Text;

            //Concatenating the variables.

            Name = First_Name + Second_Name;
           
            // Out putting the String variable.
            MessageBox.Show("Your Name is" + Name);
           
        }

In this block of Code  we have 
1.Created three string variables
            
            string First_Name;                      
            string Second_Name;           
            string Name;



2.Assigning the values of two of them 
(Firs_Name and Second_Name)

             First_Name=textBox1.Text;                    
             Second_Name = textBox2.Text;

3.Then Concatenating the First_Name & Second_Name


Name = First_Name + Second_Name;

4. Out putting the variable using Message_Box.

             MessageBox.Show ("Your Name is" + Name);


Lets Code:

Now lets create and windows form application for better understanding of Concept of Concatenation. Like before we will proceed step by step.
Step 1:
        Start a Windows Forms Application new Project in C #.
Step 2:
       Now let's add some controls to our Form.
1. First go to toolbox and add one button to your form.
2. Go to toolbox and add two Text boxes to your form.
3. Go to toolbox and add two labels to your form.
4. Change the text of labels by opening their properties.
   (Right clicking on the label and chose properties at the very end).

Our form should look like this.



Step 3:
      Now Double click on the button to give some codes to it.

Step 4:
       Creating three string variables.

            string First_Name;                      
            string Second_Name;           
            string Name;
Step 5: 
         Assigning values to two of Variables.

            First_Name= textBox1.Text;                    
            Second_Name = textBox2.Text;

Step 6:     
           type this code to Concatenating the variables.

            Name = First_Name + Second_Name;

Step 7:
        Now type or paste the following code to output them.          
            
            MessageBox.Show("Your Name is" + Name);
           
        }
Step 8: Now time to run the program. 







Friday, 16 November 2012

Variables Using C sharp

Variables Using C sharp:

Computer programmes work by manipulating data stored in memory. These storage buckets come under the general heading of Variables. Now we see how to set up and use variables. After some lessons, we will create our own calculator programme using c Sharp dot net frame work.lets get started with Strings.


Strings:

              Strings are the variables that hold " text ". 

Concept:

            to understand the concept of strings variable we take an example of some buckets.
lets spouse we have 5 buckets  these buckets will remain empty until we put some thing in them.
And we can also write some names on them so we know what they contain.   

Lets code:

For better under standing lets create a  new programme.

Step 1:

            Open new Project by clicking on New Project.

Step 2:

Our Form should look like this

              

Step 3:

           Now we will  go to toolbox and add a new button to our form.



         

Step 4:

          Chang the text of Button form buttons properties.
Now form looks like this.


Step 5:

          Now again lets go to toolbox and add a new textbox to our form.Our form should look like this.



Step 6:

         Double click on Message box button to add some code to it.





There we have to code so we can :
1. Create and variable
2. Assign a value to variable 
3. Out put the value of variable.




1. Creating a string variable:

            string Name;
This code creates a string variable or a bucket that can hold some text data and it's name is "Name"   
2. Assigning a value to String Variable (Name):
            Name = textBox1.Text;
            This Code gives the value or Text of textbox1 to Name (String Variable).
3. Out Putting the Value Saved in String variable "Name".                   
            MessageBox.Show("Your Name is "+Name);         

           This code out puts the Value saved in Name via a Message box
Now run your programme and keep coding best of luck.