muhammad ghouse pf lab manual

37
LAB MANUAL PROGRAMMING FUNDAMENTAL S. No. Lab Tasks Signature 01 LAB-1(A)- Introduction 02 LAB-1(B)- The Program Development Life Cycle 03 LAB 2(B) - Declaring Different Variables 04 LAB 3(A)- Arithmetic Operations 05 LAB 3(B)- Taking Input from Computer 06 Lab 4(A) - Conditional Statement ( IF , ELSE) 07 LAB 4(B) -Conditional Statement (Switch case) 08 LAB 5(A) -Control Statement Loops (For And While Loops)

Upload: muhammad-a-ahmed

Post on 09-Feb-2016

7 views

Category:

Documents


1 download

DESCRIPTION

This is a lab manual of PAF KIET in pdf form, my brother studies there not me. This books is being uploaded because i had to download a file that's it.

TRANSCRIPT

Page 1: Muhammad Ghouse PF Lab Manual

LAB MANUAL

PROGRAMMING FUNDAMENTAL

S. No. Lab Tasks Signature

01 LAB-1(A)- Introduction

02 LAB-1(B)- The Program Development Life Cycle

03 LAB 2(B) - Declaring Different Variables

04 LAB 3(A)- Arithmetic Operations

05 LAB 3(B)- Taking Input from Computer

06 Lab 4(A) - Conditional Statement ( IF , ELSE)

07 LAB 4(B) -Conditional Statement (Switch case)

08 LAB 5(A) -Control Statement Loops (For And While

Loops)

Page 2: Muhammad Ghouse PF Lab Manual

09 LAB 5(B) -Control Statement Loops (For Each And Do

While Loops)

10 LAB 6 - Arrays

11 LAB 7(A)- Introduction To Windows Form Application

12 LAB 7(B) - Creating Windows Form Application

13 LAB 8- Input declaration in Windows Form

Application

14 Lab 9 - Add Data Into List box From Textbox

Page 3: Muhammad Ghouse PF Lab Manual

TABLE OF CONTENT

Contents LAB-1(A) Introduction: .............................................................................................................................4

Software ..........................................................................................................................................4

1. Systems Programs ........................................................................................................................4

2. Application Programs ....................................................................................................................4

Compilers ........................................................................................................................................4 LAB-1(B) The Program Development Life Cycle .............................................................................................6

Problem Definition ..............................................................................................................................6

Problem Analysis ................................................................................................................................6

Algorithm design and representation ......................................................................................................7

Flowcharting Symbols and their meanings ...............................................................................................9

Coding and Debugging ........................................................................................................................ 10 LAB-2(A) Introduction to C#.Net: ............................................................................................................... 11 LAB 2(B) - Declaring Different Variables ..................................................................................................... 15

C# Character Escape Sequences ............................................................................................................. 15

Using Escape Sequences ...................................................................................................................... 16 LAB 3(A) Arithmetic Operations ................................................................................................................. 18 LAB 3(B) TAKING INPUT FROM COMPUTER ................................................................................................ 22 Lab 4(A) - Condition Statement ( IF , ELSE) ................................................................................................. 23 LAB 4(B) - Condition Statement (Switch case) ............................................................................................. 25 LAB 5 - Control Statement Loops ............................................................................................................... 26

While Loop ...................................................................................................................................... 26

For Loop .......................................................................................................................................... 26

For Each Loop ................................................................................................................................... 27

DO While ......................................................................................................................................... 27 LAB 6 - ARRAYS ..................................................................................................................................... 29

Two Dimension Array ......................................................................................................................... 29

Array Dimensions .............................................................................................................................. 30

JAGGED Arrays .................................................................................................................................. 30 LAB 7(A)- INTRODUCTION TO WINDOWS FORM APPLICATION ....................................................................... 31

The Toolbox ..................................................................................................................................... 32 LAB 7(B) - Creating Windows Form Application ........................................................................................... 33 LAB 8 - INPUT DECLARATION IN WINDOWS FORM APPLICATION .................................................................... 34 Lab -9 Add Data Into List box From Textbox................................................................................................ 36

Page 4: Muhammad Ghouse PF Lab Manual

LAB-1(A) Introduction: Software A software is the program that a computer uses in order to function. It is kept on some hardware device

like a hard disk, but it itself is intangible. The data that the computer uses can be anything that a

program needs. Programs acts like instructions for the processor.

Some Types of Computer Programs: 1. Systems Programs Programs that are needed to keep all the hardware and software systems running together smoothly Examples: • Operating Systems like Linux, Windows, Unix, Solaris, MacOS

2. Application Programs Programs that people use to get their work done Examples: • Word Processor • Game programs • Spreadsheets Compilers The computer understands only one language: machine language. Machine language is in the form of

ones and zeros. Since it is highly impractical for people to create programs out of zeros and ones, there

must be a way of translating or converting a language which we understand into machine language, for

this purpose, there exists compilers.

Page 5: Muhammad Ghouse PF Lab Manual

What is a Programming Language?

A programming language is a standardized communication technique for expressing instructions to a computer. Like human languages, each language has its own syntax and grammar. Programming languages enable a programmer to precisely specify what data a computer will act

upon, how these data will be stored/transmitted, and precisely what actions to take under various

circumstances.

There are different types of programming languages that can be used to create programs, but

regardless of what language you use, these instructions are translated into machine language that can

be understood by computers.

Categories of Programming Languages

1. High-level Programming Languages A high-level programming language is a programming language that is more user- friendly, to some

extent platform-independent, and abstract from low-level computer processor operations such as

memory accesses. A programming statement may be translated into one or several machine

instructions by a compiler. Examples are Java, C, C++, Basic, Fortran

2. Low-level Assembly Language

Assembly languages are similar to machine languages, but they are much easier to program in

because they allow a programmer to substitute names for numbers. Assembly languages are available

for each CPU family, and each assembly instruction is translated into one machine instruction by an

assembler program. Note: The terms "high-level" and "low-level" are inherently relative. Originally, assembly language was considered low-level and COBOL, C, etc. were considered high-level. Many programmers today might refer to these latter languages as low-level.

Page 6: Muhammad Ghouse PF Lab Manual

LAB-1(B) The Program Development Life Cycle

Programmers do not sit down and start writing code right away when trying to make a computer

program. Instead, they follow an organized plan or methodology, that breaks the process into a series

of tasks. Here are the basic steps in trying to solve a problem on the computer:

Problem Definition Problem Analysis Algorithm design and representation (Pseudocode or flowchart) Coding and debugging

Problem Definition A programmer is usually given a task in the form of a problem. Before a program can be designed to

solve a particular problem, the problem must be well and clearly defined first in terms of its input

and output requirements. Problem Analysis After the problem has been adequately defined, the simplest and yet the most efficient and effective

approach to solve the problem must be formulated. Usually, this step involves breaking up the

problem into smaller and simpler sub- problems.

Example Problem: Determine the number of times a name occurs in a list Input to the program: list of names, name to look for

Output of the program: the number of times the name occurs in a list A clearly defined problem is already half the solution.

Computer programming requires us to define the problem first before we even try to create a solution.

Let us now define our example problem: “Create a program that will determine the number of times a name occurs in a list.”

Page 7: Muhammad Ghouse PF Lab Manual

Algorithm design and representation Once our problem is clearly defined, we can now set to finding a solution. In computer programming, it is normally required to express our solution in a step-by-step manner.

An Algorithm is a clear and unambiguous specification of the steps needed to solve a problem. It may be

expressed in either Human language (English, Tagalog), through a graphical representation like a

flowchart or through a pseudocode, which is a cross between human language and a programming

language.

Now given the problem defined in the previous sections, how do we express our general solution in such a way that it is simple yet understandable?

Expressing our solution through Human language: 1. Get the list of names 2. Get the name to look for, let's call this the keyname 3. Compare the keyname to each of the names in the list 4. If the keyname is the same with a name in the list, add 1 to the count 5. If all the names have been compared, output the result

Page 8: Muhammad Ghouse PF Lab Manual

Expressing our solution through pseudocode: Let nameList = List of Names Let keyName = the name to be sought

Let Count = 0

For each name in NameList do the following

if name == keyName Count = Count + 1 Display Count

Page 9: Muhammad Ghouse PF Lab Manual

Flowcharting Symbols and their meanings A flowchart is a design tool used to graphically represent the logic in a solution. Flowcharts typically do

not display programming language commands. Rather, they state the concept in English or

mathematical notation.

Here are some guidelines for commonly used symbols in creating flowcharts. You can use any symbols in creating your flowcharts, as long as you are consistent in using them.

Page 10: Muhammad Ghouse PF Lab Manual

Coding and Debugging After constructing the algorithm, it is now possible to create the source code. Using the algorithm as basis, the source code can now be written using the chosen programming language. Most of the time, after the programmer has written the program, the program isn't 100% working

right away. The programmer has to add some fixes to the program in case of errors (also called bugs)

that occurs in the program. This process of is called debugging. There are two types of errors that a programmer will encounter along the way. The first one is compile-time error, and the other is runtime error.

Compile-Time Errors occur if there is a syntax error in the code. The compiler will detect the error and

the program won't even compile. At this point, the programmer is unable to form an executable that

a user can run until the error is fixed. Forgetting a semi-colon at the end of a statement or misspelling a certain command, for example, is a compile-time error. It's something the compiler can detect as an error. Compilers aren't perfect and so can't catch all errors at compile time. This is especially true for logic errors such as infinite loops. This type of error is called runtime error.

For example, the actual syntax of the code looks okay. But when you follow the code's logic, the same

piece of code keeps executing over and over again infinitely so that it loops. In such a case, compilers

aren't really smart enough to catch all of these types of errors at compile-time, and therefore, the

program compiles fine into an executable file. However, and unfortunately, when the end-user runs

the program, the program (or even their whole computer) freezes up due to an infinite loop. Other

types of run-time errors are when an incorrect value is computed, the wrong thing happens, etc.

Page 11: Muhammad Ghouse PF Lab Manual

LAB-2(A) Introduction to C#.Net: C# is an elegant and type-safe object-oriented language that enables developers to build a wide range of

secure and robust applications that run on the .NET Framework. You can use C# to create traditional

Windows client applications, XML Web services, distributed components, client-server applications,

database applications, and much, much more.

Namespaces Namespaces allow you to create a system to organize your code. A good way to organize your namespaces is via a hierarchical system. You put the more general names at the top of the hierarchy and get more specific as you go down. example using System; using System.Collections; using System.Data; Variable

"Variables" are simply storage locations for data. You can place data into them and retrieve their contents as part of a C# expression. The interpretation of the data in a variable is controlled through "Types".

C# is a "Strongly Typed" language. Thus all operations on variables are performed with consideration of what the variable's "Type" is. There are rules that define what operations are legal in order to maintain the integrity of the data you put in a variable. The C# simple types consist of the Boolean type and three numeric types - Integrals Floating Point Decimal and String. The term "Integrals", which is defined in the C# Programming Language Specification, refers to the classification of types that include sbyte byte short ushort int uint long

Page 12: Muhammad Ghouse PF Lab Manual

ulong, and char. The string type represents a string of characters and is discussed in The String Type section, later in this lesson. The next section introduces the boolean type.

Writing a First Program:

Step 1:

Go to Start > All Programs > Microsoft Visual Studio 2010 and open Microsoft Visual Studio 2010 Application

Page 13: Muhammad Ghouse PF Lab Manual

Step 2: Go to File > New > Project On the left Pane Select Visual C# , and on the right pane Select Console Application Step 3: Writing a Code in the Main function Area

Page 14: Muhammad Ghouse PF Lab Manual

Defining Variables and Printing static void Main(string[] args)

{ int firstvariable = 10; Console.WriteLine(firstvariable);

}

Note: int is the datatype and firstvariable is its variable and its value is 10. Secondly Console.WriteLine prints the text or variables Program Execution To RUN this program Press CTRL + F5 Output 10 Press any key to continue . . .

Q. Write a program that print the values of two variables that contains the number 12, 10 Hint: datatype will be int , Console.WriteLine Method will be used twice

Page 15: Muhammad Ghouse PF Lab Manual

LAB 2(B) - Declaring Different Variables static void Main(string[] args)

{

int firstvariable = 10; Console.WriteLine("First value is {0}", firstvariable); }

Output:

10

Press any key to continue . . .

C# Character Escape Sequences

Meaning

Escape Sequence

\' Single Quote

\" Double Quote

\\ Backslash

\0 Null, not the same as the C# null value

\a Bell

\b Backspace

\f form Feed

\n Newline

\r Carriage Return

\t Horizontal Tab

\v Vertical Tab

Page 16: Muhammad Ghouse PF Lab Manual

Using Escape Sequences Beep static void Main(string[] args)

{ int firstvariable = 10;

Console.WriteLine("First value is\b {0}", firstvariable); }

Output Beep + 10 Press any key to continue . . .

static void Main(string[] args)

{ int firstvariable = 10;

Console.WriteLine("First value is\f {0}", firstvariable); }

FormFred

NewLine static void Main(string[] args)

{ int firstvariable = 10;

Console.WriteLine("First value is \n {0}", firstvariable); }

Page 17: Muhammad Ghouse PF Lab Manual

Carrige Return static void Main(string[] args)

{ int firstvariable = 10;

Console.WriteLine("First value is \r {0}", firstvariable); }

Horizontal Tab static void Main(string[] args)

{ int firstvariable = 10;

Console.WriteLine("First value is \t {0}", firstvariable); }

Note: here tab is a distance of .5 inch Vertical Tab static void Main(string[] args)

{ int firstvariable = 10;

Console.WriteLine("First value is \v {0}", firstvariable); }

Note: Symbol represent the vertical tab

Page 18: Muhammad Ghouse PF Lab Manual

LAB 3(A) Arithmetic Operations

Addition of Integer Variables static void Main(string[] args)

{ int first = 1; int second = 2; int third = 3; Console.WriteLine(first + second + third);

} Output: 6 Press any key to continue . . .

Subtracting static void Main(string[] args)

{ int first = 1; int second = 2; int third = 3; Console.WriteLine(first - second - third);

} Output: - 4 Press any key to continue . . .

Page 19: Muhammad Ghouse PF Lab Manual

Multiplication static void Main(string[] args)

{ int first = 1; int second = 2; int third = 3; Console.WriteLine(first * second * third);

} Output: 6 Press any key to continue . . . Division static void Main(string[] args)

{ int first = 1; int second = 2; int third = 3; Console.WriteLine(first / second / third);

} Output: -0 Press any key to continue . . .

Page 20: Muhammad Ghouse PF Lab Manual

Addition of double Variables static void Main(string[] args)

{ double first = 1; double second = 2.5; double third = 3; Console.WriteLine(first + second + third);

} Output: 6.5 Press any key to continue . . .

Subtracting static void Main(string[] args)

{ double first = 1; double second = 2.5; double third = 3; Console.WriteLine(first - second - third);

} Output: - 4.5 Press any key to continue . . .

Page 21: Muhammad Ghouse PF Lab Manual

Multiplication static void Main(string[] args)

{ double first = 1; double second = 2.5; double third = 3; Console.WriteLine(first * second * third);

} Output: 7.5 Press any key to continue . . . Division static void Main(string[] args)

{ double first = 1; double second = 2.5; double third = 3; Console.WriteLine(first / second / third);

} Output: 0.1333333333 Press any key to continue . . .

Page 22: Muhammad Ghouse PF Lab Manual

LAB 3(B) TAKING INPUT FROM COMPUTER

Taking Numeric Input static void Main(string[] args)

{ int input = Convert.ToInt16(Console.ReadLine()); Console.WriteLine(input);

} Output: Give input to the Program 13 13 Press any key to continue . . . Taking Text Input static void Main(string[] args)

{ string input = Console.ReadLine(); Console.WriteLine(input);

} Output: Give input to the Program Hello World Hello World Press any key to continue . . . Taking Decimal Input static void Main(string[] args)

{ double input = Convert.ToDouble(Console.ReadLine()); Console.WriteLine(input);

} Output: Give input to the Program 13.5 13.5

Page 23: Muhammad Ghouse PF Lab Manual

Lab 4(A) - Condition Statement ( IF , ELSE)

If & else static void Main(string[] args)

{

int number;

Console.WriteLine("Please enter a number between 0 and 10:");

number = Convert.Toint16(Console.ReadLine());

if(number > 10)

Console.WriteLine("Hey! The number should be 10 or less!");

else

if(number < 0)

Console.WriteLine("Hey! The number should be 0 or more!");

else

Console.WriteLine("Good job!");

Console.ReadLine();

}

Page 24: Muhammad Ghouse PF Lab Manual

static void Main(string[] args) {

int i= 0;

Console.WriteLine("Press any Key Between 0-5"); if (i == 0)

{

Console.WriteLine("you have press 0");

}

if (i == 1)

{

Console.WriteLine("You have pressed 1");

}

if (i == 2)

{

Console.WriteLine("You have pressed 2");

}

if (i == 3)

{

Console.WriteLine("You have pressed 3");

}

if (i == 4)

{

Console.WriteLine("You have pressed 4");

{

Page 25: Muhammad Ghouse PF Lab Manual

if (i == 5)

{

Console.WriteLine("You have pressed 5");

}

else

{

Console.WriteLine("You have Pressed Incorrect Key");

}

LAB 4(B) - Condition Statement (Switch case)

static void Main(string[] args)

{ int i=0; i = int.Parse(Console.ReadLine());

switch (i) {

case 1: Console.WriteLine("You have pressed 1"); break;

case 2: Console.WriteLine("you have pressed 2"); break;

case 3: Console.WriteLine("you have pressed 3"); break;

case 4:

Console.WriteLine("you have pressed 4"); break; case 5:

Console.WriteLine("you have pressed 5"); break;

default: Console.WriteLine("Invalid key pressed"); break;

}

Page 26: Muhammad Ghouse PF Lab Manual

LAB 5(A) - Control Statement Loops (For and While)

While Loop A while loop will check a condition and then continues to execute a block of code as long as the condition evaluates to a boolean value of true. Its syntax is as follows: while (<boolean expression>) { <statements> }. public static void Main()

{ int myInt = 0;

while (myInt < 10) {

Console.Write("{0} ", myInt); myInt++;

} Console.WriteLine();

}

For Loop A for loop works like a while loop, except that the syntax of the for loop includes initialization and condition modification. for

loops are appropriate when you know exactly how many times you want to perform the statements within the loop. public static void Main()

{

for (int i = 0; i < 5; i++) {

Console.WriteLine(i);

} }

Example -2 public static void Main()

{ for (int i=0; i < 20; i++)

{

if (i == 10) break;

if (i % 2 == 0)

continue; Console.Write("{0} ", i);

} }

Page 27: Muhammad Ghouse PF Lab Manual

LAB 5(B) - Control Statement Loops (For Each and Do While)

For Each Loop The foreach loop enables iterating through each item in a container class, such as an array. static void Main(string[] args)

{

string[] names = { "Cheryl", "Joe", "Matt", "Robert" };

foreach (string person in names) {

Console.WriteLine("{0} ", person); }

}

DO While

static void Main(string[] args) {

string Mymenu = "";

int orderqty; string ordername; do {

Console.WriteLine("L - Get list of Menus"); Console.WriteLine("O - Place Order "); Console.WriteLine("Q - Quit Program");

Mymenu = Console.ReadLine();

switch (Mymenu) {

case "L": case "l":

Console.WriteLine("Vegetable Fried Rice"); Console.WriteLine("Chicken Manchorian"); Console.WriteLine("Chicken Corn Soup "); Console.WriteLine("Juice"); Console.WriteLine("Cold Drink"); Console.ReadLine(); break;

case "O": case "o"

Console.WriteLine("Place your Order"); Console.WriteLine("Please Enter The name of your Order");

Page 28: Muhammad Ghouse PF Lab Manual

ordername = Console.ReadLine(); Console.WriteLine("Please Write the quantity of the Order"); orderqty = int.Parse(Console.ReadLine());

Console.WriteLine("Your order Name is: {0} Order Quantity is: {1}",ordername,orderqty);

break;

case "Q": case "q":

Console.WriteLine("Quit"); break; default:

Console.WriteLine("Please Choose Correct Menu"); break; }

} while (Mymenu != "Q" && Mymenu != "q");

Page 29: Muhammad Ghouse PF Lab Manual

LAB 6 - ARRAYS // Declare a single-dimensional array static void Main(string[] args)

{

int[] array1 = new int[5]; array1[1] = 9; array1[2] = 8; array1[3] = 7; array1[4] = 6;

for (int i = 1; i < array1.Length; i++)

{ Console.WriteLine(array1[i]); }

}

Two Dimension Array static void Main(string[] args)

{ int[,] array = new int[,] { { 1, 2, 3 }, { 9, 8, 7 } };

int dimention1 = array.GetLength(0); int dimention2 = array.GetLength(1);

for (int i = 0; i < dimention1; i++)

{ for (int j = 0; j < dimention2; j++) {

Console.WriteLine(array[i, j]); }

}

}

Page 30: Muhammad Ghouse PF Lab Manual

Array Dimensions static void Main(string[] args)

{ int[] a1 = { 1, 2 }; int[,] a2 = { { 1 }, { 2 } }; int[, ,] a3 = { { { 1, 2 }, { 2, 1 } } };

Console.WriteLine("One Dimension Array : "+a1.Rank); Console.WriteLine("Two Dimension Array: "+a2.Rank); Console.WriteLine("Three Dimension Array: "+a3.Rank);

}

Note: We use the Rank property to get the number of dimensions for each of them.

JAGGED Arrays Arrays that have elements of the same size are called rectangular arrays. In contrast, arrays which

have elements of different size are called jagged arrays. Jagged arrays are declared and initialized

differently. static void Main(string[] args)

{

int[][] jagged = new int[][] {

new int[] { 1, 2 }, new int[] { 1, 2, 3 }, new int[] { 1, 2, 3, 4 }

};

foreach (int[] array in jagged) {

foreach (int e in array) {

Console.Write(e + " "); }

} Console.Write('\n');

}

Page 31: Muhammad Ghouse PF Lab Manual

LAB 7(A)- INTRODUCTION TO WINDOWS FORM APPLICATION Start Visual Studio.NET and create a new C# Windows Application project by selecting File | New | Project. In the dialog that appears, click Visual C# Projects in the tree to the left and then select Windows Application in the list to the right. For now, simply use the default name suggested by Visual Studio and click OK. This should bring up a window much like the one shown below:

Page 32: Muhammad Ghouse PF Lab Manual

The Toolbox

`

Page 33: Muhammad Ghouse PF Lab Manual

LAB 7(B) - Creating Windows Form Application 1. Open Visual Studio.NET and create a new C# Windows Application. Name the application ButtonTest.

2. Pin the Toolbox down, and double-click the Button control three times. Then move the buttons and resize the form as shown in the picture below: 3. Right-click a button and select Properties. Then change the Name property for each of the buttons as indicated in the picture above by selecting the Name edit field in the Properties panel and typing the text.

4. Change the Text properties of each of the three buttons to the same as the name except for the first three letters (btn).

5. We want to display a flag in front of the text to make it clear what we are talking about. Select the English button and find the Image property. Click (…) to the right of it to bring up a dialog where you can select an image. The flag icons we want to display come with Visual Studio.NET. If you installed to the default location (on an English language installation) they should be located in C:\Program Files\Microsoft Visual Studio.NET\Common7\Graphics\icons\Flags. Select the icon flguk.ico. Repeat this process with the Danish button, selecting the flgden.ico file instead (if you want to use a different flag here, then this directory will have other flags to choose from).

6. You'll notice at this point that the button text and icon is placed on top of each other, so we need to change the alignment of the icon. For both the English and Danish buttons, change the ImageAlign property to MiddleLeft.

7. At this point, you may want to adjust the width of the buttons so that the text doesn't start right where the images end. Do this by selecting each of the buttons and pull out the right notch that appear.

8. Finally, double click on the English button and add the Text

MessageBox.Show("You click On English Language");

Page 34: Muhammad Ghouse PF Lab Manual

LAB 8 - INPUT DECLARATION IN WINDOWS FORM APPLICATION

Step -1 Go to Start> All programs > Microsoft Visual Studio 2010 Step-2 Go to File> new> Project > Visual C# > Windows Form Application

Step-3 Drag the Following Controls from the Toolbox on the Blank Area 2 Labels 2 Textboxes 1 Button

Page 35: Muhammad Ghouse PF Lab Manual

Step-3 After dragging the control on the Blank area , right click on the button1 go to properties, select Text option and Rename the button to Show Result Do similar work with the labels as well Step -4 Double Click on the Button and go to coding area, as we did the sum program in the earlier labs

same code with some different syntax will be used . here is the code that will be placed in the {

Scope of button } qq double firstvalue; double secondvalue;

double total;

firstvalue = Convert.ToDouble(textBox1.Text); secondvalue = Convert.ToDouble(textBox2.Text);

total = firstvalue + secondvalue;

MessageBox.Show(total.ToString());

Page 36: Muhammad Ghouse PF Lab Manual

Lab -9 Add Data Into List box From Textbox Step -1 Drag the above Control as placed on the above figure on the blank area of C# Windows Form, the controls includes:

1 Label 1 textbox 1 Listbox Step -2 Right Click on the Textbox , go to properties, Click on the Event button as shown in the picture Step -3 In the Events options double click on Leave event

Page 37: Muhammad Ghouse PF Lab Manual

Step -4 Add the following code in Textbox_Leave scope

listBox1.Items.Add(((TextBox)sender).Text); Step -5 Run the program CTRL + F5 , give any input in the textbox and press Tab Key. your input will be shown in the ListBox

PDF to Word