1.Introduction to MS-DOS :

MS-DOS ( Disk ) was the Microsoft-marketed version of the first widely-installed operating system in personal . It was essentially the same operating system that ('s) young company developed for IBM as Personal - in 1981. Most users of either DOS system simply referred to their system as Disk Operating System. Like PC-DOS, MS-DOS was (and still is) a non-graphical line-oriented - driven operating system, with a relatively simple interface but not overly "friendly" . Its prompt to enter a command looks like this:

C:\> MS-DOS does not care about anything called an icon, wallpaper or screen saver. Rather than being considered as a (GUI) MS-DOS is what is known as a command-line interface. You commands on what is called the command line.

MS-DOS is a single-user, single-tasking computer operating system. In spite of its very small size and relative simplicity, it is one of the most successful operating systems that has been developed to date.

In DOS, a file name consists of eight character followed by a 3 character file extension. The size of a file is restricted to a 4 byte file descriptor, which limits a file’s maximum size to approximately 4 billion characters. The first release of DOS could not read or write to disk drives so users could only read and write to a floppy disc. DOS was not a state of the art operating system, even for its . Its success can be attributed only to its relative cost to other operating systems at the time it was released. However, DOS was and still is a widely-used operating system. Understanding how it came to be and how it works can lead to greater insight into the current state of computing.

2.Field of Application

- system for storage media. - File management - For single user systems only - Network client (NetBEUI, IPX/SPX, TCP/IP) - batch processing

3.Structure information

- 16-bit operating system, (formerly 8-bit) - Single tasking - command interpreter for internal and external commands - external driver software imbedding for periphery devices possible

4.System environment

- minimum: 512 Kbytes RAM, 5 Mbyte hard disk storage (depends on version for full installation) - FAT . - executable with every compatible CPU - low RAM and fixed storage disk needs

5.The Command Prompt

The command prompt - this is where you will see any output produced. This screen, among being called a command prompt, is often referred to as simply a DOS prompt, command line or a MS-DOS prompt.

All versions of have had an MS-DOS like command- line interface (CLI).

How to get to a MS-DOS prompt / Windows command line

Windows NT, 2000, XP, Vista, and 7 users

1. Click Start. 2. Click Run. 3. Type cmd and press enter.

Otherwise, if you are using an older version of Windows, type command into the Run box and click "OK". You could also type command.exe

After you click "OK", an MS-DOS command prompt window will appear. Depending upon which version of Windows you are using, the MS-DOS command window will look similar to this image:

The standard window displays white text on a black background. This color combination may make text difficult to read. To make the window display black text on a white background, type the command: color f0 (that's the letter f followed by the digit zero 0). To go back to the standard of white text on a black background, type: color

This is called the command prompt or DOS prompt. The flashing underscore next to the command prompt is called the cursor. The cursor shows where the command you type will appear.

6.MS-DOS Commands

1- Viewing the Contents of a Directory ()

To view the contents of a directory Type the following at the command prompt:

C:\> dir A list similar to the following appears:

2-Make Directory (md)

Allows you to create your own directories in MS-DOS.

C:\>md test The above example creates the "test" directory in the directory you are currently in. md c:\test Create the "test" directory in the c:\ directory.

3- Change Directory ()

The cd command is an internal command used to switch directories in MS-DOS cd\ Goes to the highest level, the root of the drive. cd.. Goes back one directory cd Typing cd alone will the .

4- Remove Directory ( rd)

Removes empty directories in MS-DOS. To delete directories with files or directories within them the user must use the deltree command.

5- IP Configuration ( ipconfig ) Useful for troubleshooting your internet connection. Displays the current IP address of your computer and the DNS server address. If you call your ISP (Internet Service Provider) for reporting a bad internet connection, he will probably ask you to run ipconfig.

To get your computers local network IP address, subnet mask, and default gateway typing ipconfig alone will display this information as shown below. Keep in mind this is only your local network information.

6- File Attributes () attrib allows a user to change the properties of a specified file. Using attrib, the user has the capability of changing the file to have any of the below attributes. attrib +r

Add the read-only attribute to a file so it cannot be modified until the read only attribute is taken off. attrib +h

Add the hidden attribute to the file causing it to be not be seen by the average user. attrib -h

This command will do the opposite of the above command. Instead of hiding the file it will unhide the file if hidden.

7- edit

Edit allows a user to view, create, and/or modify their computer files Edit is only able to open a file with a maximum of 65,280 lines. If you are running a MS-DOS version 4.x or lower or you are unable to edit on your .

8- type

Allows the user to see the contents of a file

TYPE [drive:][]

9-

Allows the user to copy one or files to an alternate location. copy *.* a:

Copy all files in the current directory to the drive. copy myfile1.txt+myfile2.txt

Copy the contents in myfile2.txt and combines it with the contents in myfile1.txt.

10-

Cls is a command that allows a user to clear the complete contents of the screen and leave only a prompt.

11- date

The date command can be used to look at the current date of the computer as well as change the date to an alternate date. Date Display the current date and prompt for a new one. If no date is entered, the current date will be kept.

12- Rename

Used to rename files and directories from the original name to a new name.

RENAME [drive:][path][directoryname1 | filename1] [directoryname2 | filename2] [drive:][path][directoryname1 | filename1] [directoryname2 | filename2]

Note that you cannot specify a new drive or path for your destination.

Windows 1-Introduction

Microsoft Windows is a series of software operating systems and graphical user interfaces produced by Microsoft Company. Microsoft first introduced an named Windows in November 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces (GUIs). Microsoft Windows came to dominate the world's market, overtaking Mac OS*, which had been introduced in 1984. As of October 2009, Windows had approximately 91% of the market of the client**operating systems for usage on the Internet. The most recent client version of Windows is ; the most recent server version is 2008 R2; the most recent mobile OS version is 7.

Windows 1.0, the first version, released in 1985

2- Windows7

Windows 7 is the latest release of Microsoft Windows, a series of operating systems produced by Microsoft for use on personal computers, including home and business desktops, laptops, Netbooks***

* Mac OS is the trademark-protected name for a series of graphical user interface-based operating systems developed by Apple Inc. **client is an application or system that accesses a remote service on another computer system, known as a server, by way of a network *** Netbooks are a category of small, lightweight, and inexpensive laptop computers that omitted certain features and offered reduced specification and computing power. tablet PCs*, and media center PCs. Windows 7 cuts the fat from the Vista release and promises to correct some of the wrongs found in the former release. Vista started off on rocky terrain. Many of the accessories commonly used on a desktop just wouldn’t work. It was months before many manufacturers came out with compatible drivers for video cards, printers, scanners, cameras, webcams, and the like. It’s these types of problems that forced business owners to retain XP.

32-bit and 64-bit Windows:

The terms 32-bit and 64-bit refer to the way a computer's processor (also called a CPU), handles information. The 64-bit version of Windows handles large amounts of random access memory (RAM) more effectively than a 32-bit system. In simple terms, the data path on a 32-bit operating system is half the size of 64-bit operating systems. That means that your computer can be slogging twice as much data around at any given time with a 64-bit OS. In order for a 64-bit version of Windows to be of value to you, you will also need a 64-bit processor and 64-bit versions of the software that you plan to run. Without all three, you would be wasting your time.

To find out if your computer is running a 32-bit or 64-bit version of Windows in Windows 7 or , do the following:

1. Open System by clicking the Start button, right-clicking Computer, and then clicking Properties.

* tablet PC (tablet personal computer) is a portable personal computer equipped with a screen as a primary input device.

2. Under System, you can view the system type. If your computer is running Windows XP, do the following:

1. Click Start.

2. Right-click My Computer and then click Properties.

• If you don't see "x64 Edition" listed, then you're running the 32-bit version of Windows XP.

• If "x64 Edition" is listed under System, you're running the 64-bit version of Windows XP.

To install a 64-bit version of Windows 7, you need a CPU that's capable of running a 64-bit version of Windows. The benefits of using a 64-bit operating system are most apparent when you have a large amount of random access memory (RAM) installed on your computer, typically 4 GB of RAM or more. In such cases, because a 64-bit operating system can handle large amounts of memory more efficiently than a 32-bit operating system, a 64-bit system can be more responsive when running several programs at the same time and switching between them frequently. The 64-bit version of Windows can run faster because it can address more physical memory (generally referred to as RAM – Random Access Memory) and avoid using the much slower hard drive for active memory needs. The 32-bit limitation for RAM access is at 4 GB which means as soon as Windows needs more working memory it has to swap out information in temporary free space created on the hard drive (referred to as the swap file) and this is only if you have that much RAM installed.

To run a 64-bit version of Windows, your computer must have a 64-bit- capable processor. To find out if your processor is 64-bit-capable in Windows 7 or Windows Vista, do the following:

1. Open Performance Information and Tools by clicking the Start button , and then clicking Control Panel. In the search box, type Performance Information and Tools, and then, in the list of results, click Performance Information and Tools.

2. Do one of the following:

• In Windows 7, click View and print detailed performance and system information.

• In Windows Vista, click View and print details. • Select the command you wish to add from the drop-down list. It will appear in the Quick Access toolbar.

The Save, Undo, and Redo commands appear by default in the Quick Access toolbar. You may wish to add other commands to make using specific Word features more convenient for you.

To Display or Hide the Ruler: • Click the View Ruler icon over the scrollbar.

The View Ruler icon works as a toggle button to turn the ruler on and off. To Drag and Drop Text: • Select the text you wish to copy. • Left-click your mouse and drag the text to the location you wish it to appear. The cursor will have a text box under it to indicate that you are moving text.

• Release the mouse button and the text will appear.

The following Topics will clarified online in the lecture using MS-word program with data show device.

1: Setting Up Your Word Environment 2: Text 3: Saving Documents 4: Proofing Features 5: Printing 6: Creating a New Document 7: Formatting Text 8: Working with Text boxes 9: Inserting Clip Art 10: Working with Shapes 11: Working with Lists 12: Line and Paragraph Spacing 13: Modifying Page Layout 14: Working with Pictures 15: Working with Headers and Footers 16: Working with Tables 17: Using Indents and Tabs 18: Applying Styles and Themes

From here, you can access important options such as New, Save, Save As, and Print. By default the Quick Access Toolbar is pinned next to the Microsoft Office Button, and includes commands such as Undo and Redo. At the bottom, left area of the , you will find worksheet tabs. By default, three worksheet tabs appear each time you create a new workbook. On the bottom, right area of the spreadsheet you will find page view commands, the zoom tool, and the horizontal scrolling bar.

To Zoom In and Out: • Locate the zoom bar in the bottom, right corner. • Left-click the slider and drag it to the left to zoom out and to the right to zoom in. To Scroll Horizontally in a Worksheet: • Locate the horizontal scroll bar in the bottom, right corner. • Left-click the bar and it from left to right.

To Change Page Views:

• Locate the Page View options in the bottom, right corner. The Page View options are Normal, Page Layout, and Page Break. • Left-click an option to select it. To Add Commands to the Quick Access Toolbar: • Click the arrow to the right of the Quick Access toolbar. • Select the command you wish to add from the drop-down list. It will appear in the Quick Access toolbar. • Select More Commands from the menu and a dialog box appears. • Select the command you wish to add.

• Click the Add button. • Click OK. The following Topics will be clarified online in the lecture using (MS- Excel 2007) program with data show device.

1: Setting Up Your Excel Environment 2: Starting a Workbook 3: Modifying Columns, Rows, & Cells 4: Formatting Text 5: Creating Simple Formulas 6: Working with Cells 7: Printing Workbooks 8: Creating Complex Formulas 9: Working with Basic Functions 10: Sorting, Grouping, and Filtering Cells 11: Formatting Tables 12: Aligning Text 13: Working with Worksheets.

H.W: Compose the following table where the columns and rows titles are written with font type 'Arial' size 14 with bold effect in the center of the table's cell. Also the cell width should be 15 units.

Your table should contain suitable relations to achieve the following: 1- Calculate the mark's average of each student and list it in column F which is named as "Average". 2- If the Average was more than 50 degree then the word "pass" is written in the column G under the "status" otherwise the word "Fail" is written in the status cell. 3- Calculate the "Grade" of each student. 4- Draw the following curves to specify student Marks for each subject:

Continued to the Lecture 2 (Windows)

3-What is Windows 7? Windows 7 is the next version of Microsoft Windows Operating System (OS). Windows 7 was released to manufacturing on July 22, 2009, and reached general retail availability on October 22, 2009, less than three years after the release of its predecessor, Windows Vista.

4- Why the name “Windows 7”?

Windows 7 is the seventh OS by Microsoft so “Windows 7”. Windows 7 is based on the feedback taken from the end users using Windows Vista. Windows 7 has better ways to find and manage and to you speed through everyday tasks. It's designed for faster and more reliable performance, so your PC just works the way you want it to.

1

3- A new accessibility feature is the Windows Key plus (+) key gives the screen an instant zoom like the second Google search picture, and the minus key (-) returns the resolution to the normal size like the first Google search picture.

3

6- Comparisons between Win 7 and Win Vista

7- Why People prefer Win 7 than other kinds of windows?

1- Window 7 is simple to use, more responsive , full of new possibilities and also better desktop PC performance (faster than others types of windows). 2- The taskbar has bigger buttons and full-sized previews , and you can pin programs to it for one-click access. 3- Jump Lists provide shortcuts to files, folders, and websites (Right click on the specified program Windows taskbar).

4

4- Peek gives you the power of X-ray vision, so you can peer past all your open windows straight to the Windows 7 desktop. Simply point to the end of the taskbar and watch open windows instantly turns transparent). Snap is a quick new way to resize open windows, simply by dragging them to the edges of your screen. Shake is to quickly minimize every open window except the one you're shaking. This feature can save you time if you want to focus on a single window without minimizing all your other open windows one by one. You can then restore all of those windows by shaking the open window again. Pictures below show Peek and Shake features respectively.

Peek in windows 7

5

Shake in windows 7

5- Smarter search . Type in the Start menu search box and you'll see results instantly, grouped by category: documents, pictures, music, -mail, and programs.

6- Search in a folder or library and you can fine-tune your search with filters like date or file type; and use the preview pane to peek at the contents of your results. See the pictures below.

6

7- Easy sharing with Home Group . Sharing files and printers on your home network should be simple. Connect two or more PCs running Windows 7, and with a minimum of fuss you can start sharing music, pictures, videos, and documents with other people in your home. 8- Built for speed . Windows 7 has key performance improvements to take up less memory and run background services only when you need them. It's designed to run your programs faster and to sleep, resume, and reconnect to wireless networks quicker. 9- Better wireless networking . Connecting to wireless networks on your laptop just by a couple of clicks. Choose from the list of available networks in the taskbar, click one, and then connect. Once you've

7

8- Versions of Windows 7 Windows 7 Enterprise, Windows 7 Home Professional, Windows 7 Home Basic, Windows 7 Home Premium, Windows 7 Ultimate and Windows 7 Starter.

9- Copy and Paste files to a New Folder

Copy and Paste operations of files from the source to destination locations are very important features in windows. In this section, you will learn how to copy and paste any type of file (s) to a new folder. Let's start by creating a new folder.

1- Start the Windows 7 Explorer by clicking its icon to the right of the Start button (Circled by the black line):

2- When Windows Explorer starts, click on Local Disk C: in the Left-Hand Side.

9

3- Create a folder by clicking the New Folder button at the top:

4- The new folder appears, with blue highlighted text:

10

The blue highlight means that you can go ahead and type a new name for that folder. In the New folder below, we've changed the name to University of Technology :

If you've clicked away from the new folder, click back on to it once with your left mouse button. Pause for a second or two and then click again with your left mouse button. It should turn blue again. If it doesn't, right click the new folder and select "Rename" from the menu that appears (if you need to rename it again). Now that you have a new folder called University of Technology folder, you need to add file (s) to it. 5- Use the Navigation pane on the top to navigate to a location on your computer where you have file (s). In the Desktop, we've found some files that need to be copied to the C:\University of Technology folder. (If you

11

have files on a USB stick or data card, insert it and then click Computer. Your USB stick or data card should show up there as a drive.)

6- Once you've found some files, select the ones you want to add to your C:\University of Technology folder. To select one file, simply click it with your left mouse button. To select more than one file, hold down the left CTRL key on your keyboard. With the CTRL key held down, click each file you want to add. If you've made a mistake, click the file again to deselect it. Once you have selected your files, right click on any of them. From the menu that appears select Copy :

12

7- Now navigate back to the University of Technology folder you have just created in the C:\. Double click the University of Technology folder to move inside of it. You should see a message on the right saying " this folder is empty ". Right click anywhere inside of the big white area , and right-click again . From the menu, select Paste. 8- The files will be copied and pasted over to the University of Technology folder as follow:

13

14

9- To delete file (s) using windows, just select any file (s) that want to be deleted using the same procedure described above, then Right click From the menu select Delete operation. For example, consider the following pictures that show you how Delete is working under windows:

15

1- Introduction Word 2007 is the greatest word processing application from Microsoft. It is used for creating letters to more complex documents like newsletters, manuals, forms. Known as a Graphical User Interface (GUI) it uses windows, icons, pull-down menus, and the mouse to make us ing the program easier to learn. It is recommended that during the installation of Office 2007 you also uninstall your older version(s) of Office (like Office 2003) . Although you can have multiple versions installed at the same time you will encounter problems. The most notable issue is trying to open two versions of one program. For example,

1

If you open both Word 2003 and Word 2007 , then restart your computer you will find that Word will not open right away. In fact, your computer will need to reinstall upon trying to open Word 2003 or Word 2007 taking a considerable amount of time.

2- How to Open Word 2007 from the Start Button

‹ Click the Start button.

2

‹ Click the All programs

‹ Click Microsoft Office

3

‹ Click Microsoft office Word 2007

4

a. Title bar i. File name, format , application b. Quick Access Toolbar i. Save , Undo , redo , and the toolbar is completely customizable

c. The Office button i. Similar to the Word 2003 File menu

5

ii. New, Open, Convert, Save, and so on… Those with arrows have additional commands you can choose

d. Buttons in bottom right 1. Word Options 2. Exit Word

6

e. The Zoom Slider

f. Document View Buttons

3- Create New Document

Documents can be basic letters to more complex documents like newsletters, manuals, forms. They need to be saved if you want to work with them again.

7

a. When opening Word 2007 it automatically starts with a new document b. To close that document, select Office Button > Close c. Creating a new document, select Office Button > New. d. In the top middle of the new window under Black and recent click on Blank Document and then select the Create button in the bottom right of t he window.

8

e. Saving a document i. Try to save your files when you begin to prevent the possibility of losing your document later due to some random computer failure ii. To save a document, select Office Button > Save or Save As 1. This time, simply choose Save 2. Select My Documents as the location to save a. This is the default location to save b. This is the best to save all of your files as it is easy to back up this folder c. You can also make folders within the My Documents folder f or better organization 3. Give the file a name, mywordfile 4. Word Document will save as a Word 2007 document (.docx) and is not compatible with older versions unless the compatibility package was installed on the computer that tries to open the file iii. Keyboard sh ortcut: Ctrl+S iv. To save as an older 1. Select Office Button > Save As > Word 97 -2003 a. This will save as a .doc 2. In the Title bar it now shows the document is a . doc and you are working in the Compatibility Mode a. This means that you will not have the n ew Word 2007 specific features b. This also means your Word 97-2003 document is compatible with the older versions of Word v. Close this file, create a new Word 2007 document and save as a yourname.docx

9

10

4- Visual aids Visual aids help you with creating and editing your documents. They help with the layout and design in getting you precise measurements and better ways to view

a. Rulers i. On the Ribbon, select the View > in the Show/Hide group > click Ruler ii. The ruler s show the page by inches iii. In the top and left rulers there are Margin Markers indicated by the division of white and blue iv. The arrows, boxes, and L’s indicate indenting and tabs

11

b. Zoom i. 125% default ii. Zoom Slider 1. Bottom right corner iii. View Tab 1. Zoom One page, two pages, 100% and so on… iv. Easiest way to zoom Ctrl + [your mouse scroll]

5- Orientation

Two different ways to layout your document a. On the Ribbon, select the Page Layout tab > in the Page Setup group > click Orientation > Portrait or Landscape

6- Margins A margin is the space between the text and the edge of the printed paper at the top, bottom, left, and right of the page a. Margins by default if changed will change for the entire document

12

i. To change the margin visually, simply move your mouse pointer into the left margin on the ruler and then click and drag to set your new margin ii. To change the margin by using exact numbers 1. On the Ribbon, select the Page Layout tab > in the Page Setup group > click Margins 2. Select one of the predesigned margins or select Custom Margins and change the settings in the new window

13

7- Formatting Text

Formatted text has control codes indicating the fonts , bold or italic type , margins , indents, columns, tabs, headers and footers

a. Resize text i. Select any letter, number, word, sentence, or paragraph ii. On the Ribbon, select the Home tab > in the Font group > click A or A iii. On the Ribbon, select the Home tab > in the Font group > click on the down arrow to open a menu of different sizes, then hover over some of the sizes and watch how the text in the document changes

14

b. Basic style changes i. On the Ribbon, select the Home tab > in the Font group > Hover over: 1. B for Bold 2. I for italics 3. U for Underline

c. “Highlighting” text i. “Highlight ” selected text 1. Select any letter, number, word, sentence, or paragraph 2. On the Ribbon, select the Home tab > in the Font group > click Text Highlight Color (down arrow for dropdown menu) a. Choose Yellow

ii. “Highlight ” any text

15

1. Do not select any text 2. On the Ribbon, select the Home tab > in the Font group > click Text Highlight Color (button) 3. Simply click and drag over the text you want to “highlight” 4. To turn the “highlighter ” off select the Text Highlight Color button again iii. To get rid of a text “ highlight ” 1. Select the text that has the highlight 2. On the Ribbon, select the Home tab > in the Font group > click Text Highlight Color (down arrow for dropdown menu) > No Color

8- Navigating Documents

Navigation is the way you move around in your document. There are many keyboard shortcuts and options in the Scrollbar to move to different sections of your document

a. Using standard keys on your keyboard i. Use the Arrow key on the keyboard to move up or down one line, or left or right one character

16

ii. Page Up and Page Down keys move up or down one page at a time

b. Using keyboard shortcuts i. Ctrl + Page Up and Ctrl + Page Down keys take you to the top of the previous page or the next page ii. Ctrl + End key takes you to the very end of your document iii. Ctrl + Home key takes you to the very top of the document

17

c. Using the Scrollbar feature i. On the far right of your screen click on the up arrow to move up and on the down arrow to move down ii. Click and drag the slider in between the two arrow to change what you view iii. Click in between the arrows and the slider and you will move up or down more quickly

d. The Mouse Wheel allows you to scroll up or down

18

9- Cut, Copy, Paste, and Move text These are options for you to cut , copy , paste , or move selections of text and other objects in you document

a. Copy and Paste one word i. Select any word ii. On the Ribbon, select the Home tab > in the Clipboard group > Copy iii. Click into the new location for the word you copied iv. Right-click on your mouse and from the menu choose Paste from the menu v. Keyboard shortcuts 1. Copy - Ctrl+C 2. Paste - Ctrl + V

19

a. Cut and Paste one word vi. Select any word vii. On the Ribbon, select the Home tab > in the Clipboard group > Cut viii. Click into the new location for the word you copied ix. Right-click on your mouse and from the menu choose Paste from the menu x. Keyboard shortcuts 1. Cut - Ctrl+X 2. Paste - Ctrl + V

20

b. Move text xi. Select any word xii. Click (and don’t let go) inside the selected word xiii. Drag your mouse to the desired location and drop (let go of the mouse button) the text 10- Undo and Redo

Commands that allow you to correct mistakes by moving backward or forward in time a. Click at the end of the document in an empty row (no text in row) b. Type: Today c. Demonstrate using the keyboard shortcuts i. Undo - Ctrl+Z ii. Redo - Ctrl+Y

21

11- Printing After you complete writing your document, you can print it.

To Preview the Document Before Printing:

Select Print Print Preview . The document opens in Print Preview format.

In Print Preview format, you can do many tasks including:

‹ Modify the margins . ‹ Change page orientation .

22

‹ Change the page size . ‹ Zoom in and out to view various parts of the document . ‹ View multiple pages . ‹ Access Word Options to change many Word settings .

To Print:

Click the Microsoft Office Button .

Select Print Print . The Print dialog box appears.

Select the pages you would like to print -- either all pages or a range of pages.

Select the number of copies.

Check the Collate box if you are printing multiple copies of a multi -page document.

Select a from the drop -down list.

23

12- Working with Text Box

To Insert a Text box :

Select the Insert tab on the Ribbon .

Click the Text Box command in the Text group .

Select a Built-in text box or Draw Text Box from the menu.

If you select Built-in text box , left-click the text box you wish to use and it will appear in the document. OR

If you select Draw Text Box , a cursor will be shown on the word paper . Left- click you r mouse and while holding it down, drag your mouse until the text box is the desired size.

24

25

13- Working with Shapes

You can add a variety of shapes to your docu ment including arrows, squares, stars, flowchart symbols and more. Select the Insert tab on the Ribbon .

Select the Shapes command . Your cursor is now a cross shape.

Left-click your mouse and while holding it down, drag your mouse until the shape is the desired size.

Rel ease the mouse button.

26

14- Working with Table s

A table is a grid of cells arranged in rows and columns. Tables can be customized and are useful for various tasks such as presenting text information and numerical data.

Select the Insert tab on the Ribbon . Then select Tables

27

28

Control & Systems Engineering Department St 1 Class Computer Programming Lecturer Ass. Saba T. Salim

Visual Basic Language is a programming language and development environment created by Microsoft. It is an extension of the BASIC programming language that combines BASIC functions and commands with visual controls. Visual Basic provides a graphical user interface GUI that allows the developer to drag and drop objects into the program as well as manually write program code.

1. The Development Environment

Learning the ins and outs of the Development Environment before you learn visual basic is somewhat like learning for a test you must know where all the functions belong and what their purpose is. First we will start with labeling the development environment. 2. What Is Visual Basic?

Visual Basic is an object-oriented programming development system for creating applications that run under any of the Microsoft Windows environments. It has the following two major components: 1. An extensive collection of prewritten tools, called controls. These controls are accessible as icons within a graphical programming environment for creating customized windows components (e.g., menus, dialog boxes, text boxes, slide bars, etc.). 2. A complete set of program commands, derived from Microsoft’s implementation of the classical Basic programming language. The command set includes features that embrace contemporary programming practices. The overall approach to Visual Basic programming is twofold: 1. Create a user interface that is appropriate to the particular application at hand. 2. Add a group of Basic instructions to carry out the actions associated with each of the controls. 3. Visual Basic Program Components

In Visual Basic, a program is referred to as a project. Every Visual Basic project consists of at least two separate files – a project file (whose extension is .vbp), and a file (with extension .frm). Some projects include multiple form files and other types of files, such as class module (.cls) files, standard module (bas) files, resource (.res) files, and ActiveX control (.ocx) files. Thus, the development of a Visual Basic project

1 - 13 Control & Systems Engineering Department 1St Class Computer Programming Lecturer Ass. Saba T. Salim involves keeping track of several different files, and accessing these files individually within the Visual Basic environment, as needed.

4. Object-Related Concepts

Forms: In Visual Basic, a window is called a form. Each form includes a title bar at the top. Some applications are based upon a single form, while others require two or more forms. Figure below shows a simple form containing a command button control and several text box control and two labels (see the figure below).

Figure (1) Controls: The icons with which the user interacts are called controls. Commonly used controls include command buttons, option buttons, check boxes, labels, text boxes, picture boxes and menus. The user will typically activate a control (e.g., click on a command button) to produce an event as shown in figure above. Objects: Forms and controls are referred to collectively as objects. Most objects are associated with events; hence, objects may include their own unique event procedures. Objects are also associated with their own properties and methods. Properties: Objects include properties that generally define their appearance or behavior. The choice of properties depends on the type of object. For example, the name, caption, height, width, background color, location and font are some of the more common properties associated with a command button.

2 - 13 Control & Systems Engineering Department 1St Class Computer Programming Lecturer Ass. Saba T. Salim

Methods: Some objects also include special program statements called methods. A method brings about some predefined action affecting the associated object. For example, show is a method that can be used with a hidden form to make it visible.

5. The Visual Basic Environment For running Visual basic go through the following steps: Start >> programs >> Microsoft visual basic 6.0 The following window will appears on your Windows Desktop. You may then enter the workspace for a new project by selecting New/Standard.EXE, or by selecting New Project from the File menu (see the figure below). Or, you may open an existing project by selecting either the Existing tab or the Recent tab, and then selecting the particular project that is of interest. Still another way to open an existing project is to select Open Project from the File menu, and then select the particular project of interest.

Figure (2)

If you choose to create a new project, you will see a group of windows similar to that shown in Fig below. The Visual Basic IDE (Integrated Design Environment) is made up of a number of components:

3 - 13 Control & Systems Engineering Department 1St Class Computer Programming Lecturer Ass. Saba T. Salim

 Title Bar The top line is called the Title Bar. It includes the project name, an icons that minimize the group of windows, change the size of the group, or close Visual Basic on the right.  Menu Bar The second line is called the Menu Bar. Selecting one of the choices (File, Edit, View, Project, and Format . . . Help) causes one of Visual Basic’s drop-down menus to appear.

Figure (3)

 Toolbar The third line is called the Standard Toolbar. The icons on this line duplicate several of the more commonly used menu selections that are available via the drop-down menus accessed from the Menu Bar.

 Form Design and Project Container Windows The Form Design Window is where the user interface is actually designed. This is accomplished by selecting the desired Control Icons from the Toolbox and placing them in the Form Design Window.

4 - 13 Control & Systems Engineering Department 1St Class Computer Programming Lecturer Ass. Saba T. Salim

 Toolbox The Toolbox contains icons that represent commonly used controls, such as a , text box, command button, picture box, check box, and so on. You can select a control from the Toolbox and place it in the current Form Design Window by double-clicking on the control icon (thus placing the control in the center of the window), or by clicking once on the control icon, then clicking on the desired location within the Form Design Window and dragging the mouse so that the control has the desired size. Once a control has been placed in the Form Design Window, the associated code (i.e., the associated Visual Basic instructions) can be viewed or edited by double-clicking on the control.

Figure (4)

5 - 13 Control & Systems Engineering Department 1St Class Computer Programming Lecturer Ass. Saba T. Salim

Table 1: Tools in the Visual Basic Toolbox

Icon Tool Name What This Tool Does

Pointer Selects objects

Picture box Draws a box to display graphics

Label Draws a box to display text

Text box Draws a box that can display text and let the user type in text

Frame Groups two or more objects together

Command button Draws a command button

Check box Draws a check box

Option (or radio) Draws a radio button button

Combo box Draws a combo box

List box Draws a list box

Horizontal scroll Draws a horizontal scroll bar bar

Vertical scroll bar Draws a vertical scroll bar

Timer Places a timer on a form

Drive list box Draws a drive list box that displays all the disk drives available

Directory list box Draws a directory list box that displays a directory on a particular disk drive

File list box Draws a file list box that displays files in a specific

6 - 13 Control & Systems Engineering Department 1St Class Computer Programming Lecturer Ass. Saba T. Salim

directory

Shape Draws a geometric shape such as a circle or a square

Line Draws a line

Image box Draws a box to display graphics

Data control Draws a control to link a program to a file

OLE Draws a box to insert an OLE object

Figure (5)

 Properties Window We have already learned that every object has properties associated with it. Each object has its own unique list of properties. The Properties Window allows you to assign or change the properties associated with a particular object (i.e., a particular form or control).

7 - 13 Control & Systems Engineering Department 1St Class Computer Programming Lecturer Ass. Saba T. Salim

 Project Window The Project Window displays a hierarchical list of the files associated with a given project. These files represent individual forms and modules. You can display a form or module within the Project Container Window by double-clicking on the corresponding icon within the Project Window. Also, you can select either the Object View or the Code View by clicking on one of the two leftmost icons within the toolbar at the top of the Project Window.

 Code Editor Window If you select Code View within the Project Window, or if you double- click on a control icon within the Form Design Window, the Code Editor Window will open, displaying the Visual Basic code associated with the currently active form. Figure below shows the Code Editor Window containing an event procedure (i.e., the Visual Basic code associated with a command buttons).

 Form Layout Window The Form Layout Window allows you to specify the screen location of the forms within a project. To change the form location, simply drag the form icon to the desired position.

6. Repositioning, Resizing, Deleting, Adding, and Docking Windows

Any of the individual windows can be repositioned (by activating the window and then dragging it to the desired location), resized (by activating and then dragging an edge or corner), or deleted (by clicking on the in the upper right corner). A window can be added by selecting the window name from the View menu. The interface may become messy if several windows have been moved and/or resized. When this happens, Visual Basic allows the windows to be returned to their orderly, pre-assigned position. This is called docking. Docked windows are always aligned alongside their neighbors, and they are always visible. To dock a window that has been moved from its pre-assigned position, simply double-click on the window’s title bar. For any window, docking can be overridden by selecting Options/Docking from the Tools menu, and then selecting or deselecting the appropriate check boxes.

8 - 13 Control & Systems Engineering Department 1St Class Computer Programming Lecturer Ass. Saba T. Salim

7. Opening an Existing Visual Basic Project

We have already seen that an existing project can be accessed by locating the project name listed under the Existing or the Recent tab within the New Project window (see Fig. 2), or by locating the project via File/Open Project. Once the project is opened, however, the Form Design Window may not be visible within the Project Container Window. To access the Form Design Window, you may have to expand the Forms icon within the Project Window and then select the desired form. Double-click on the form icon to show the Form Design Window.

8. Saving a Visual Basic Project

Saving a project can be tricky in Visual Basic because it involves saving multiple files. To save a new Visual Basic project for the first time, choose Save Project As from the File menu. You will be prompted separately for a form name (i.e., the name of the .frm file) and a project name (the .vbp file). Usually, the same name is given to both files. To save an updated version of a previously saved project, click on the Save Project button in the Toolbar or select Save Project from the File menu. This will cause the current version of the project files to be saved under their existing names.

Figure (6)

To save a previously saved project under a different name (this is the tricky part), you must save each file separately under its new name. Thus, you should first save each form file under the new name, and then save the project file under the new name. If you simply save the project file under a different name, the form files will retain their old names; this may cause problems when switching between the old version and the new version of the project.

9. Running a Visual Basic Project

9 - 13 Control & Systems Engineering Department 1St Class Computer Programming Lecturer Ass. Saba T. Salim

To execute a Visual Basic project, simply click on the Start button in the Toolbar (see Fig 6), or select Start from the Run menu. The execution can be temporarily suspended by clicking on the Break button, or by selecting Break from the Run menu. The execution of a paused project can then be resumed by clicking on the Run button, or by selecting Continue from the Run menu. To end the execution, simply click on the End button, or select End from the Run menu.

10. Getting Help Visual Basic also includes an excellent on-line help facility, which will answer most questions and provide detailed information, with examples, of various Visual Basic features. To access the help feature, press function key F1 or select Contents, Index or Search from the Help menu.

11. Steps in Developing Application

There are three primary steps involved in building a Visual Basic application: 1. Draw the user interface 2. Assign properties to controls 3. Attach code to controls

We’ll look at each step…

Example 1: Stopwatch Application The idea of this project is to start a timer, then stop the timer and compute the elapsed time (in seconds).

Step 1- Drawing Controls

1. Start a new project.

2. Place three command buttons and six labels on the form. Move and size the controls and form so it looks something like this: Figure (7)

10 - 13 Control & Systems Engineering Department 1St Class Computer Programming Lecturer Ass. Saba T. Salim

Step 2- Assign properties

Each form and control has properties assigned to it by default when you start up a new project. There are two ways to display the properties of an object. The first way is to click on the object (form or control) in the form window. Then, click on the Properties Window or the Properties Window button in the tool bar. The second way is to first click on the Properties Window. Then, select the object from the Object box in the Properties Window. Shown is the Properties Window for the stopwatch application:

Figure (8)

The drop-down box at the top of the Properties Window is the Object box. It displays the name of each object in the application as well as its type. This display shows the Form object. The Properties list is directly below this box. In this list, you can scroll through the list of properties for the selected object. You may select a property by clicking on it. Properties can be changed by typing a new value or choosing from a list of predefined settings (available as a drop down list). Properties can be viewed in twoways: Alphabetic and categorized. Figure (9)

11 - 13 Control & Systems Engineering Department 1St Class Computer Programming Lecturer Ass. Saba T. Salim

A very important property for each object is its name. The name is used by Visual Basic to refer to a particular object in code. Object names can be up to 40 characters long, must start with a letter, must contain only letters, numbers, and the underscore (_) character. Names are used in setting properties at run time and also in establishing procedure names for object events.

Now, Set properties of the form, three buttons, and six labels:

Form1: Border Style:1-Fixed Single Caption: Stopwatch Application Command1: Caption: &Start Timing Name: cmdStart Command2: Caption: &End Timing Name: cmdEnd Command3: Caption: E&xit Name: cmdExit Label1: Caption: Start Time Label2: Caption: End Time Label3: Caption: Elapsed Time Label4: Border Style 1-Fixed Single Caption: [Blank] Name: lblStart Label5: Border Style: 1-Fixed Single Caption: [Blank] Name: lblEnd Label6: Border Style: 1-Fixed Single Caption: [Blank] Name: lblElapsed

In the Caption properties of the three command buttons, notice the ampersand (&). The ampersand precedes a button's access key. That is, in addition to clicking on a button to invoke its event, you can also press its access key (no need for a mouse). The access key is pressed in conjunction with the Alt key. Hence, to invoke 'Begin Timing', you can either click the button or press Alt+B. Note in the button captions on the form, the access keys appear with an underscore (_).

12 - 13 Control & Systems Engineering Department 1St Class Computer Programming Lecturer Ass. Saba T. Salim

Your form should now look something like this:

Figure (10)

The third part of this example will be continued in the next lecture

13 - 13 Control & Systems Engineering Department 1St Class Computer Programming Lecturer Asst. Saba T. Salim

Before we complete the third step of the example solution, we will try to clarify three important things these are: 1): some of the properties that related the controls that used in the example as an attempt to learn the benefits of these properties and 2): Code Editor Window and finally: variables used by visual basic to hold information.

1) Command Button & labels properties

Property Description Name The name of the object so you can call it at runtime This specifies the command button's background color. Click the BackColor's palette down arrow to see a list of common BackColor Windows control colors, you must change this to the style property from 0 - standard to 1 - graphical Determines whether the command button gets a Click event if Cancel the user presses escape Caption Holds the text that appears on the command button. Determines whether the command button is active. Often, Enable you'll change the enable property at runtime with code to prevent the user pressing the button Produces a Font dialog box in which you can set the caption's Font font name, style and size. Height Positions the height of the object - can be used for down Left Positions the left control - can be used for right Mouse If selected to an icon can change the picture of the mouse Pointer pointer over that object Hold's the name of an icon graphic image so that it appears as a Picture picture instead of a Button for this option to work the graphical tag must be set to 1 This determines if the Command Button appears as a standard Style windows dialog box or a graphical image Tab index Specifies the order of the command button in tab order Whether the object can be tabbed to ( this can be used in labels Tab Stop which have no other function )

2

Control & Systems Engineering Department 1St Class Computer Programming Lecturer Asst. Saba T. Salim

If the mouse is held over the object a brief description can be Tool Tip displayed (for example hold your mouse over one of the above Text pictures to see this happening If you want the user to see the button/label select true otherwise Visible just press false Width Show the width of the object

Most of These properties can be set or changed either manually from the object properties window or using the programming code, we must note here that the property (Name) is changed using the project properties window only. And if you try to change it using the programming code then the following error message will appear:

Figure (1) And using several properties your form may looks like the following:

Figure (2)

3

Control & Systems Engineering Department 1St Class Computer Programming Lecturer Asst. Saba T. Salim

2) Code Editor Window

If you select Code View within the Project Window, or if you double-click on a control icon within the Form Design Window, the Code Editor Window will open, displaying the Visual Basic code associated with the currently active form. Fig. 1.4 shows the Code Editor Window of our form shown in figure (2).

Event selected by the programmer

Provided automatically

Figure (3)

Ignore the individual Visual Basic instructions for now. Notice, however, the two list boxes at the top of the window. The leftmost list box showing the Object List box; it allows you to select the event procedures associated with a particular object (e.g., a particular command button, form, label, text box, etc.). The rightmost list box is called the Procedure List box; for the current

4

Control & Systems Engineering Department 1St Class Computer Programming Lecturer Asst. Saba T. Salim object, it allows you to select the event procedure associated with a particular type of event (e.g., Click, DragDrop, KeyDown, MouseDown, etc.). To define the event procedure associated with a command button, double-click on the button. This will cause the Code Editor Window to be displayed, as shown in Fig. 3 Within this window, the first and last line of each event procedure (e.g., Private Sub Command1_Click) and (End Sub) are provided automatically, separated by a blank line. The actual Visual Basic commands must be inserted between these two lines. You can also set or modify properties while your application is running. To do this, you must write some code. The code format is: FormName.ObjectName.Property = NewValue BackColor property of a form name command1, we'd type: Command1.BackColor = vbblue the expression (vbred) is a function provided by visual basic programming language allows you to add preferred color beyond the function (vb) or you can use the function (QBcolor) followed by a color number as in the table shown later: Command1.BackColor = QBColor(01) The names you assign to objects are used by Visual Basic to set up a framework of event-driven procedures for you to add code to. The format for each of these subroutines (all object procedures in Visual Basic are subroutines) is: Sub ObjectName_Event (Optional Arguments) . . End Sub Visual Basic provides the Sub line with its arguments (if any) and the End Sub statement. You provide any needed code.

Color Number Color Number Black 0 Light Blue 9 Blue 1 Light Green 10 Green 2 Light Cyan 11 Cyan 3 Light Red 12 Red 4 Light Magenta 13 Magenta 5 Light Yellow 14

5

Control & Systems Engineering Department 1St Class Computer Programming Lecturer Asst. Saba T. Salim

Yellow 6 Bright White 15 White 7 Grey 8 Also we can change the "Caption" property using the programming code as follows: Command1.caption="close" Or you may change the command button activity using Enable property through the programming code as follows: Command1.enabled=false (true) The properties of changing dimensions or Caption font formatting can be changed also through the programming code as follows:

Command1.width=No. Command1.Hight=No. Command1.Left=No. Command1.Top=No.

Command1.FontSize=No. Command1.FontItalic = True(False) Command1.fontBold=True(False) Command1. FontUnderline=True(False) Command1.Font="Times New Roman" Figure (4)

Note: The property (Name) of a command button or Label control objects can be changed only through the properties window of the object.

3) Variables and Constants. Variables are used by Visual Basic to hold information needed by your application. Rules used in naming variables: Þ No more than 255 characters. Þ They may include letters, numbers, and underscore (_) with no spaces. Þ The first character must be a letter. Þ You cannot use a reserved word (word needed by Visual Basic).

Data Type Occupied . Suffix Data Type Occupied vol. Suffix Integer 2 byte % Byte 1 byte None

6

Control & Systems Engineering Department 1St Class Computer Programming Lecturer Asst. Saba T. Salim

Long 4 byte & Boolean 2 byte None Single 4 byte ! Currency 8 byte @ Double 8 byte # String 2 byte $ Date 8 byte None Variant 16 byte None There are two principle ways to add variables to your applications: The first method – called implicit declaration – is to let Visual Basic automatically create the variable for you. Implicit declaration means that Visual Basic automatically creates a variant for each identifier it recognizes as a variable in an application. To implicitly type a variable, use the corresponding suffix shown above in the data type table. For example,

Amount% = 300 TextValue$ = "This is a string"

The second approach to declaring variable is to explicitly declare them with one of the following keywords: Dim, Static, Private, and Public. The syntax for explicitly declaring a variable is quite simple:

Code: VB Dim VariableName As DataType Static VariableName As DataType Private VariableName As DataType Public VariableName As DataType

In each case, the name of the variable and its data type are provided as part of the declaration. Dealing with the variables requires knowledge of two main concepts related to the variables that are 1) Life time of the variable: the period that the variable keeps its value. 2) Scope (visibility): the program ability to reach and use the variable. Before allocating storage space for a variable, decide what the variable's lifetime will be, or in other words, which procedures and which modules should have access to the variable's value.

There are four levels of scope:

Þ Procedure level Þ Procedure level, static

7

Control & Systems Engineering Department 1St Class Computer Programming Lecturer Asst. Saba T. Salim

Þ Form and module level Þ Global level

9 Within a procedure, variables are declared using the Dim statement:

Dim MyInt as Integer Dim MyDouble as Double Dim MyString, YourString as String

The life time of this type is started as we declare the variable using the above statements within an event to the end of that event. And the visibility will be thorough that event only.

9 To make a procedure level variable retain its value upon exiting the procedure; the Dim keyword with Static:

Static MyInt as Integer Static MyDouble as Double

The life time of this type of variables is maintained to the end of the program i.e the variable will keep it value every time the event that hold the variable is occurred while the visibility will be thorough that event only.

9 Form (module) level variables retain their value and are available to all Procedures within that form (module). Form (module) level variables are declared in the declarations part of the general object in the form's (module's) code window. The Dim or Private keyword is used:

Dim MyInt as Integer Dim MyDate as Date

9 Global level variables retain their value and are available to all procedures within an application. Module level variables are declared in the declarations part of the general object of a module's code window. Use the Global or Public keyword:

Global MyInt as Integer Global MyDate as Date

8

Control & Systems Engineering Department 1St Class Computer Programming Lecturer Asst. Saba T. Salim

It would certainly be easier to make every variable Global. You wouldn't have to think twice about it's availability at any given time. But sometimes, every byte of memory counts, so don't give your variables any more life than they actually require.

Figure (5) Procedure Routine1 has access to X, Y, and A (loses value upon termination) Procedure Routine2 has access to X, Y, and B (retains value) Procedure Routine3 has access to X, Z, and C (loses value).

Now, we can get back to step three of our design example (attaching code): All that’s left to do is attach code to the application. We write code for every event a response is needed for. In this application, there are three such events: clicking on each of the command buttons. 1. Double-click anywhere on the form to open the code window. Or, select ‘View Code’ from the project window. 2. Click the down arrow in the Object box and select the object named (general). The Procedure box will show (declarations). Here, you declare three form level variables:

9

Control & Systems Engineering Department 1St Class Computer Programming Lecturer Asst. Saba T. Salim

Option Explicit Dim StartTime As Variant Dim EndTime As Variant Dim ElapsedTime As Variant

The Option Explicit statement forces us to declare all variables. The other lines establish StartTime, EndTime, and ElapsedTime as variables global within the form. The overall code is shown below:

Option Explicit Dim starttime As Variant Dim endtime As Variant Dim elapsedtime As Variant

Private Sub cmdend_Click() endtime = Now elapsedtime = starttime - endtime Label2.Caption = Format(endtime, "hh:mm:ss") label3.Caption = Format(elapsedtime, "hh:mm:ss") End Sub

Private Sub cmdexit_Click() End End Sub

Private Sub cmdstart_Click() starttime = Now Label1.Caption = Format(starttime, "hh:mm:ss") Label2.Caption = "" label3.Caption = "" End Sub

10

Control & Systems Engineering Department 1St Class Computer Programming Lecturer Asst. Saba T. Salim

Figure (6)

11

Control & Systems Engineering Department 1St Class Computer Programming Lecturer Asst. Saba T. Salim

12