• No results found

COMPUTER PROGRAMMING FOR BUSINESS (BMGT 121)

N/A
N/A
Protected

Academic year: 2021

Share "COMPUTER PROGRAMMING FOR BUSINESS (BMGT 121)"

Copied!
27
0
0

Loading.... (view fulltext now)

Full text

(1)

COMPUTER PROGRAMMING FOR BUSINESS (BMGT 121)

TABLE OF CONTENTS

1. Course outline ... 2

2. Week1-6: Introduction to computer programming and office automation ... 3

2.1. Definition of Programming ... 3

2.2. IT concepts ... 3

5.1. Ms Word Advanced ... 9

5.2. Ms Excel Advanced ... 10

5.3. Introduction to Ms Access ... 10

5.3.1. Access Database Objects ... 10

5.3.2. Data Types ... 10

5.3.3. Create a Database in MS Access 2007 ... 11

5.3.4. Access Forms ... 11

5.3.5. Create Table ... 11

5.3.6. Queries ... 11

5.3.7. Reports ... 12

6. 4. Week7-8: Introduction to computer programming concepts and tools ... 12

6.1. Definition of Key terminologies ... 12

6.2. Flow charting, algorithms and pseudocodes... 13

6.3. Introduction to computer programming languages ... 15

7. Week 9-13: Visual Basic Programming for Business Application Development ... 16

7.1. Introduction to VB environment and features ... 16

7.2. Form design and Windows Application Forms in VB ... 19

7.3. Coding VB procedures ... 19

14.1. Testing and Debugging ... 27 15. Idea ... Error! Bookmark not defined.

(2)

Course outline

KABARAK UNIVERSITY COURSE CODE: BMGT 121

COURSE NAME: COMPUTER PROGRAMMING FOR BUSINESS LECTURER: KAMAU GG

Email: [email protected]

Pre-requisite: None, however knowledge in Introduction to Computers and ICT applications will be a great advantage.

COURSE OBJECTIVES

The objectives of this course are to enable students to :

1. Provide the learner with an opportunity to use computers to solve business and economic problems

2. Develop the learner’s skills in the use of computer applications (word-processing, spreadsheets and advanced personal productivity skills)

3. Equip learners with end user programming skills using Ms Access to create data entry forms, tables, queries and reports

4. Introduce learners to programming concepts 5. Gain basic computer programming skills

COURSE CONTENT

1. Week1-6: Introduction to computer programming and office automation a. Using Microsoft Word to automate office documents

b. Using Ms Excel for Data Analysis automation

c. Ms Access end user programming (create tables, forms, queries and reports)

2. Week7-8: Introduction to computer programming (computer programming terminologies, types of computer programming languages, software development life cycle. flow charting, programming tools)

3. Week9-13: Visual Basic Programming for Business Application Development

ASSESSMENT

CATS (Individual assignments, group assignment, sit-in CAT) 30%

FINAL EXAM 70%

TOTAL 100%

REFERENCES (Recommended)

Gordon S.R. (2004). Information Systems 3rd Ed. Wiley & Sons *

Williams, Brian K et al. (1999). Using Information Technology: A Practical Introduction to Computers &

Communication. Boston: Irwin/McGraw-Hill Inc.

And any other texts on the subject

*Available in the KABU library

(3)

1.

Week1-6: Introduction to computer programming and office automation 1.1. Definition of Programming

In ordinary sense a program is a set of instructions to achieve an objective. It is written in a language suitable for the user who then executes its in order to achieve the desired results. Therefore, computer programming refers to the coding, testing and debugging of some instruction code in a computer understandable language to be executed by the computer. Programming concepts includes study on tools and techniques that programmers use to create new software. Software development process is a very involving process. Many times software required by a business may be available off-the-shelf for one to buy as need be. However, not all off-the-shelf solutions satisfy the needs of the business. At times the off-the shelf packages may also be expensive and such software does not allow one to modify the code to me their specific needs. When this is the case then an organization shall have to develop its own software. As a professional worker in an organization you may need to develop your own short term applications to meet some needs before any need to hire a professional. This is called end user programming, which is programming done by persons who are not ICT programming specialist.

1.2. IT concepts

Definition of a computer

A computer is a programmable electronic device that accepts data input to process it using some set of instructions (programs) so as to produce some output information.

Components of a computer system

A computer system comprises of two primary components - Hardware and software.

Hardware refers to the computer physical parts which are further divided into input devices, the central processing unit (CPU), output devices, and storage devices.

Software on the other hand is categorized into systems software and application software. System software are programs that are required by the computer in order to make it be ready for its functions.

They include operating systems and utility programs. Operating systems are programs that are used to support basic computer operations from the time it is powered on until it is shut down. It functions as the platform on which a computer user runs all their user specific programs. Utility programs are variety of programs that can be added to a computer so as to extend functionality of the computer by creating additional functions not necessarily primary to the operating system but give enhanced user environment and some housekeeping functions. For example anti-virus, CD writing software, video player, calculator, etc.

Applications software refer to a variety of programs for user specific tasks. The choice of an application program depends on the type of user and what one wants to do. For example accounting packages, architectural programs, word processing programs, etc.

Assignment: Identify FIVE application programs that can used in a large wholesale business.

Types of computers

Computers can be categorized as follows;

- Analog vs digital: An analog computer is a form of computer that uses the continuously-changeable aspects of physical phenomena such as electrical, mechanical, or hydraulic quantities to model the

(4)

problem being solved. In contrast, digital computers represent varying quantities of measurement using discrete values of two digits 0,1 called binary digits. Digital computers are the proper meaning of a computer today.

- Dedicated (special purpose) vs general purpose computer: A dedicated computer is a computing device that is designed by the manufacturer to carry out only one function. It refers to a number of intelligent devices that have some microprocessor to automate them. For example, electronic fuel pump, ATM machine, electronic washing machine, digital television, etc. General purpose computers on the other are computers that can be modified to perform any functions by loading the necessary software. Business application computers are general purpose and therefore can be programmed with variety of user applications.

According to size/processing capacity

Therefore, today’s computer systems fall into one of the following categories:

1. Supercomputers 2. Mainframe Computers

3. Minicomputers or Midrange Computers 4. Microcomputers

Supercomputers:

• Most powerful computer made

• Physically they are the largest

• Process huge amounts of data

• Can house thousands of processors

• Relatively rare because of size and cost.

• Used by large corporations, universities and government agencies.

Mainframe Computers

• Used in large organizations like insurance companies, and banks where many people need frequent access to the same data, which is usually organized into one or more databases.

• Airlines, Government Agencies (Federal Aviation Administration and Census Bureau) track information about large populations, individual tax records, payroll, and more.

• Are being used more and more as specialized servers on the World Wide Web, enabling companies to offer secure transactions with customers over the Internet.

• Many enterprises are connecting personal computers and personal computer networks to their mainframe system. This allows access to the mainframe data and services and also enables them to take advantage of local storage and processing, as well as other features of the PC or network.

• Houses an enormous volume of data (literally billions of records)

• Mainframe can occupy entire rooms or even an entire floor of a high-rise building.

Special air conditioning systems are used to keep them cool and on raised floors to accommodate all the wiring needed to connect the system.

Minicomputers

(5)

• Abbreviated version of mainframe computers.

• The capabilities are somewhere between mainframes and PC.

• Minicomputers can handle much more input and output than personal computers can.

• Designed for a single user, most are designed to handle multiple terminals.

• Can be used as a server for PC’s Microcomputers

• The microcomputer is “the computer for the masses” and personal computing

• Microcomputers include the following types: Desktop models, including workstations, notebook computers (laptops), Network Computers (netbooks), Mini laptops and Handheld personal computers, PDAs

Data Representation inside a computer

All data stored in a computer is coded into binary digits. However, computer data coding can also use a number of other data coding systems including octal and hexadecimal. Below is some examples to illustrate the arithmetic conversions and operations of these number systems including decimal systems.

2.

Binary

• Base or radix 2 number system

• Binary digit is called a bit.

• Numbers are 0 and 1 only.

• Numbers are expressed as powers of 2.

• 20 = 1, 21 = 2, 22 = 4, 23 = 8, 24 = 16, 25 = 32, 26 = 64, 27 = 128, 28 = 256, 29 = 512, 210 = 1024, 211 = 2048, 212 = 4096, 212 = 8192, …

Conversion of binary to decimal ( base 2 to base 10) Example: convert (110011)2 to decimal

= (1 x 25) + (1 x 24) + (0 x 23) + (0 x 22) + (1 x 21) + (1 x 20)

= 32 + 16 + 0 + 0 + 2 + 1

= (51)10

Conversion of decimal to binary (base 10 to base 2) Example: convert (51)10 to binary

51 / 2 = 25 remainder is 1 25 / 2 = 12 remainder is 1 12 / 2 = 6 remainder is 0 6 /2 = 3 remainder is 0 3 / 2 = 1 remainder is 1 1 / 2 = 0 remainder is 1

Read the remainders bottom up Answer = 1 1 0 0 1 1

Octal

• Base 8 or radix 8 number system

(6)

• 1 octal digit is equivalent to 3 bits.

• Numbers are 0-7.

• Numbers are expressed as powers of 8. 80 = 1, 81 = 8, 82 = 64, 83 = 512, 84 = 4096.

Conversion of octal to decimal ( base 8 to base 10) Example: convert (632)8 to decimal

= (6 x 82) + (3 x 81) + (2 x 80)

= (6 x 64) + (3 x 8) + (2 x 1)

= 384 + 24 + 2

= (410)10

Conversion of decimal to octal (base 10 to base 8) Example: convert (177)10 to octal

177  8 = 22 remainder is 1 22 ¸ 8 = 2 remainder is 6 2  8 = 0 remainder is 2

Note: the answer is read from bottom to top as (261)8, the same as with the binary case.

Hexadecimal

• Base or radix 16 number system

• 1 hex digit is equivalent to 4 bits.

• Numbers are 0-9, A, B, C, D, E, and F.

• (A)16 = (10)10, (B)16 = (11)10, (C)16 = (12)10, (D)16 = (13)10, (E)16 = (14)10, (F)16 = (15)10

• Numbers are expressed as powers of 16.

• 160 = 1, 161 = 16, 162 = 256, 163 = 4096, 164 = 65536, …

Conversion of hexadecimal to decimal ( base 16 to base 10) Example: convert (F4C)16 to decimal

= (F x 162) + (4 x 161) + (C x 160)

= (15 x 256) + (4 x 16) + (12 x 1)

= 3840 + 64 + 12

= (3916)10

Conversion of decimal to hex (base 10 to base 16) Example: convert (77)10 to hex

77 ¸ 16 = 4 remainder is D 4 ¸ 16 = 0 remainder is 4

Note: the answer is read from bottom to top as (4D)16, the same as with the binary case.

(7)

Decimal Binary Octal Hexadecimal

0 0000 0 0

1 0001 1 1

2 0010 2 2

3 0011 3 3

4 0100 4 4

5 0101 5 5

6 0110 6 6

7 0111 7 7

8 1000 10 8

9 1001 11 9

10 1010 12 A

11 1011 13 B

12 1100 14 C

13 1101 15 D

14 1110 16 E

15 1111 17 F

3.

Figure 1 - Table of Binary, Decimal and Hexadecimal Numbers

Conversion of Octal and Hex to Binary

Conversion of octal and hex numbers to binary is based upon the the bit patterns shown in the table above and is straight forward. For octal numbers, only three bits are required. Thus 68 = 1102, and 3458 = 111001012. For hex numbers, four bits are required. Thus E16 = 11102, and 47D16 = 100011111012.

Conversion of Binary to Octal and Hex

Conversion of binary numbers to octal and hex simply requires grouping bits in the binary numbers into groups of three bits for conversion to octal and into groups of four bits for conversion to hex. Groups are formed beginning with the LSB and progressing to the MSB.

Thus, 111001112 = 3478 and 111000101010100100012 = 70252218. Similarly, 111001112 = E716 and 110001010100001112 = 18A8716.

(8)

4.

Binary Arithmetic

Binary Addition

+ 0 1

0 0 1

1 1 10

Binary Addition Table

The entry for 1+1 is 10 which indicates a carry of 1

Examples

Addend 1011 1011 1011 1011 1011

Augend + 100 + 100 + 100 + 100 + 100

Obtain the sum for the above

Binary Subtraction

Uses the same principle of "borrowing" that decimal subtraction uses.

- 0 1

0 0 1 (with a borrow from the next column)

1 1 0

Binary Subtraction Table

Example

borrow 01 01 01 0 0

Minuend 10100 10100 10100 10100 10100 10100

Subtrahend - 1001 - 1001 - 1001 - 1001 - 1001 - 1001 Difference 1 11 011 1011 01011

Note: This problem in decimal is 20 – 9 = 11 which is the answer we get in binary.

Character set encoding systems

A character is a digit, an alphabet or a symbol that can be stored and manipulated by a computer. They 0,1,2...9, A,B,C,...Z, a,b,c, .... Z, ,.:;'"[]{}|\, etc. The American Standard Code for Information Interchange and the Extended Binary Coded Decimal Interchange Code are two character encoding schemes; which are more commonly known by their respective acronyms, ASCII and EBCDIC. The main difference between the two is the number of bits that they use to represent each character. EBCDIC uses 8 bits per character while the original ASCII standard only used 7, due to concerns that using 8 bits for characters that can be represented with 7 is much less efficient.

(9)

The main consequence of that difference is the number of characters that can be accommodated with each one. EBCDIC can accommodate up to 28 characters for a total of 256 while the 27 of ASCII has a maximum of 128 characters.

Although EBCDIC was very popular, due largely to the popularity of IBM machines at the time, it had several problems that irritated programmers. The first one is how it arranges the letters of the alphabet. In ASCII, all the letters are in consecutive order. Capital letters are grouped together while small letters also have their own group. In EBCDIC, the letters are grouped 9 at a time. This non- intuitive layout comes from the EBCDIC’s punch card origins and is quite difficult for programmers to deal with.

IBM’s hold of the EBCDIC coding has led to many problems when it comes to updates. ASCII and EBCDIC later had updates to increase the number of characters that they can accommodate. ASCII pages had some code points replaced while maintaining most of the other code points. With EBCDIC, the different versions are highly incompatible with each other.

As the encoding needs of computer outgrew both ASCII and EBCDIC, other standard emerged. The most recent is Unicode, which incorporated ASCII. The first 128 characters of Unicode are from ASCII.

This lets Unicode open ASCII files without any problems. On the other hand, the EBCDIC encoding is not compatible with Unicode and EBCDIC encoded files would only appear as gibberish.

Summary:

Therefore, EBCDIC uses 8 bits while ASCII uses 7 bits.

4.1. Ms Word Advanced

A word processor is an application whose principal function is the preparation of documents, reports and letters. Microsoft Word is an example of a word processing package. Other variations include Open Office and Word Perfect.

Mail Merge

Mail merge is a function in word that lets the user prepare one document and then send to many recipients whose details are stored in a database (or a data file).

To start the mail merge wizard select Tools > Letters and mailings > Mail merge wizard, and follow the wizard to create a form letter (or use an existing one) and then create a data file (or use an existing one), then insert the merge fields into the form letter, and when done preview the merged letters or click finish to complete the merging. On completing the merging the user ends up with three files; the form letter which contains the standard letter that contains common information for all the recipients, then the data file that contains the database of the contacts and other variable information. The merged file on the other hand shall contain all the letters created from a single form letter and the data file addresses. This is a very important tool in automating office letters and other documents such as reports.

(10)

4.2. Ms Excel Advanced

Microsoft Excel is a spreadsheet software. A spreadsheet is a software that is used for tabulating data such as financial reports, statistical analysis and mathematical data. It is a powerful tool for decision modeling such as product costing, break-even analysis, goal seeking, etc.

In a business environment a number of financial applications are important, and can easily done using Ms Excel. They include cash-flow analysis, pricing catalogue, receipts, invoices, profit and loss accounts, balance sheets, etc.

Exercise:

Assume you are setting up a small business that shall be issuing quotations, invoices, and receipts.

Design a template of these documents and a cash-flow projection for your first year of business.

Tips

Learn how to use formula and functions, auto-fill, re-calculate, etc

4.3. Introduction to Ms Access

Ms Access is a database management system (DBMS). A database is a collection of related records such as students marks register, inventory, bank account holders, etc. A record is a collection of related fields and usually is represented by a row in case of relational database. A field on the other hand is a characteristic of an object or an entity that is been stored in the database. For example in the student's marks register database, each individual student will be a record. Then characteristics of a student such as Name, DateofBirth, CourseCode shall be fields.

4.3.1. Access Database Objects

Tables contain rows called records and columns called fields.

Queries are requests for specific information from a database.

Forms are parts of user interface. Forms are used to enter, edit or browse data from a database Reports present requested information and allow to create hard copies.

4.3.2. Data Types Text

Memo Numbers Byte Integer

Long integer Single Double Date/time Currency AutoNumber Yes/No among others

(11)

4.3.3. Create a Database in MS Access 2007 Click on the round Office button

Choose New from the drop-down menu

In Create Blank Database window specify the database name Click Create

4.3.4. Access Forms Create using Form Wizard Create using Form Design view

Specify source of data will be presented by the form Table

Query

Specify fields related to the form Add labels, titles, graphics and so on

In the Form Design View

Form Header –a place for titles, graphics, additional information

Form Details section – the fields used to create a form and control elements related to the fields Form footer –a place for any items which will appear at the bottom of the form

To view a Form Open database

Click Forms tab to display all available forms in the database Select the form

Select Open

To view data use Form Navigation Tools. To prevent data Editing, use Locked Property for the Text Boxes

4.3.5. Create Table Using Wizard Design View Specify field names Data types

Properties

Determine a primary key Save the table

Design view

Table structure is created and may be edited Datasheet view

Display table content in spreadsheet-like grid, Used for entering, editing or deleting data from tables

4.3.6. Queries

Specify the source of data

If multiple tables are used, specify relationships between tables

Select desirable fields from the table(s) and options related to the fields

(12)

Specify a criterion

To be selected a record must satisfy a criterion Expressions may contain the following operators:

Math Operators (+,-,/,*)

Relational operators (=,>,<,<=,>=,<>) Boolean Operators (AND, OR, NOR, XOR)

String Operators and Miscellaneous Operators (&,Like, In, Is Null, Between .. And..)

4.3.7. Reports

Reports present table contents or query results in an easily assimilated format Reports have Design view and Print Preview

Report Design View is similar to the Form Design view With a Wizard

Design view:

Specify source for the report Select Fields from the Fields List Add labels

Add format

Switch the view to see the result.

Understanding Report Design View

Page Header contains data and graphics appearing at the top of each page

Report Header contains the data and graphics appearing at the top of the first report page Detailed section contains data from tables or queries

Page Footer contains the data and graphics appearing at the bottom of every page

Report Footer contains the data and graphics appearing at the bottom of the last report page

5.

4. Week7-8: Introduction to computer programming concepts and tools 5.1. Definition of Key terminologies

A Program: Is a set of instructions a computer follows in order to perform a task

A Programming Language: Is a special, high level language used to write computer programs Computers can only follow instructions

A computer program is a set of instructions on how to solve a problem or perform a task

In order for a computer to compute someone’s gross pay, we must tell it the steps to perform. When the steps are stated in our human language we call them algorithms. However, the common practice is to abbreviate these steps in our own colloquial vocabulary. This abbreviated colloquial vocabulary in for the algorithm is called pseudocode.

For example an algorithm for the computation of Net pay above might be as follows Start

Enter the basic pay, allowance, deductions Let NetPay=Basic pay + allowance -deductions Display NetPay

Stop

(13)

5.2. Flow charting, algorithms and pseudocodes

Algorithms and pseudocodes cannot execute in a computer but they provide a means of visualizing what the programming is doing and helps the programmer design his or her code.

Together with the pseudocode the programmer shall design a flow chart to represent the a diagrammatical view of the flow of program logic.

Example

What is a flow chart? Draw a flow chart for obtaining NET PAY for 10 employees who earn a BASIC PAY and HOUSE ALLOWANCE. The employees’ pay PAYE and some take ADVANCE pay. Write some algorithm for the flowchart.

A Flowchart is a diagrammatic tool for modeling the flow of logic in program design. It shows the input, processes, decisions and output of the program and thus acts as visual aid to program development

(14)

Algorithm Start

‘connector number 1 is placed here

INPUT BasicPay, Allowance, Advance, PAYE

LET NetPay = BasicPay + Allowance – Advance – PAYE OUTPUT NetPay

LET Count=Count + 1 IF Count=10 THEN Stop ELSE GOTO 1

STOP

(15)

5.3. Introduction to computer programming languages

Since a computer cannot understand our normal language, its programs are written in a coding language that is understandable to it. This language is called a computer language. There are two levels of programming languages, namely;

- Low Level Programming Language - High Level Programming Language

Low Level Programming Langauges

Low level programming language is a language for coding programs that is close to the hardware design or circuitry of the computer. It includes two types of computer languages - machine language and assembly language. This code is easier for the computer to execute but laborious for the programmer. Machine language is the lowest type of programming language where all the coding is in binary digits 0,1 such that it directly executes on the computer without any translation. However, although such coding executes very fast, coding on this language can be extremely laborious to the programmer and such programs are machine dependent and so one program cannot be used on another different machine. This coding is therefore used only in hardware abstraction layer programming such as microprocessor programming by computer scientists. Assembly language on the other hand is a programming language that uses abbreviations called mnemonics for its commands and instructions. For example, MULT, ADD, DIV, SUB, etc. It is easier to use than machine language but still laborious for the programmer. Although it needs translation to machine language by a tool called an assembler, it is still faster to execute that the high level language codes. Therefore, it is also used in programming the hardware abstraction layer of the computer but not for business programming.

High Level Programming Languages

High level language refers to programming language that is closer to normal English language and therefore easier for the programmer to code but requires to be converted into computer sensible format. It includes Fourth Generation Languages (4GLs) and Natural language, e.g. C++, Visual Basic, FoxPro etc.

Other terminologies used with programming languages

Object code versus source code

Object code is the code that is generated when a High Level Language or Assembly Language is converted into Machine Language by a Compiler.

Source code is the original program code as coded by the programmer before compiler converts it to object code.

Compiler versus Interpreter

Compiler is a programming tool that converts a high level language source code to a machine code equivalent at once to generate a new object code, e.g. Visual Basic has a compiler tool integrated into it.

An interpreter is a programming tool that converts a high level language code to machine code a statement at a time, normally it does not generate a new object code.

(16)

What are the Steps to Program?

(1) Define the Problem (2) Design a Solution (3) Develop an Algorithm (4) Code the Program (5) Test the Program (6) Document the Program

6.

Week 9-13: Visual Basic Programming for Business Application Development 6.1. Introduction to VB environment and features

Visual Basic is 4GL programming language that is also Object Oriented Programming Language, and Structured Programming Language. It uses a Graphical User Interface (GUI) for its user interaction and provides an Integrated Development Environment (IDE).

- Object Oriented Programming places the code and data in a single location called an object.

- Structured programming is a logical structure of a program that makes writing code more efficient and simpler to modify. Structured programming is easier to fix/ modify as well as work faster when trying to solve a problem. An advantage of using structured design is the capability to reduce the use of the GOTO statement. (Although some structured program languages do support the GOTO statement.)

- Graphical User Interface (GUI) is a programming environment that enables the programmer to interact with visual objects rather than memorizing keystrokes for commands. It therefore provides a user friendly programming environment.

Visual Studio is an integrated development environment, often abbreviated as IDE

• Provides everything needed to create, test, and debug software including:

• The Visual Basic language

• Form design tools to create the user interface

• Debugging tools to help find and correct programming errors

• Visual Studio supports other languages beside Visual Basic such as C++ and C#

History of Computer Science Languages

FORTRAN ( 1957 ) Science

COBOL ( 1959 ) Business Data Processing BASIC ( 1964 ) Hobby, Non-Professionals

C ( 1969 ) AT & T

C ++ ( 1987 ) AT & T Object - Oriented Visual Basic ( 1991 ) Visual Design Interface

Java ( 1993 ) Web Applications ( True OOP language ) C # ( 2001 ) A Mixture of Java and C - Web Applications

The Future Natural Languages

(17)

A Review of Structured Programming

Declaring Variables and Constants

double Gross_Pay = 0.0;

The above statement declares a variable named Gross_Pay that is initialized to 0 and is going to hold a real number with decimal points.

int counter = 0;

The above statement declares a variable named counter that is initialized to 0 and is going to hold a real number without decimal points.

Data Types

char character

bool Boolean

double Real

int Integer

float Real ( less precision )

Three Types of Program Control

- Sequence ( in a step by step order ) - Selection ( making a decision ) - Repetition ( looping )

Review Questions

(1) The language of a computer program is the same as the __________ .

(a) logical design (b) syntax

(c) flowchart (d) philosophical orientation

(2) An information system will transform __________ .

(a) wisdom into data (b) wisdom into knowledge

(c) information into data (d) data into information

(3) A parallelogram in a flowchart represents __________ .

(a) input (b) output

(c) an assignment statement (d) input and output

(18)

(4) In computer programming, the symbol to sum two numbers is __________ .

(a) ! (b) @ (c) # (d) + (e) &

(5) Which is true about variables?

(a) The underscore is the only symbol that can be used in a variable name.

(b) The name must be on the keyword list.

(c) The name is created by the compiler.

(d) The name is generated by the Java design environment.

(e) The name must start with a capital letter.

(6) Which mathematical operation is performed first in an equation with no parentheses?

(a) Addition (b) Division

(c) Exponentiation (d) Integer division

(7) Which is true about an assignment statement?

(a) They store user key strokes.

(b) They store user mouse clicks.

(c) They put the results of an operation in a variable.

(d) They display information at a prompt.

(e) They display strings in a message box.

(8) Printing a document is a type of __________ .

(a) assignment (b) input

(c) output (d) assignment and input

(9) Which data type uses double quotation marks?

(a) string (b) character

(c) decimal (d) integer

(10) Pseudocode is __________ .

(a) data that have been encoded for security (b) the incorrect results of a computer program (c) a program that does not work

(d) the obscure language computer personnel use when speaking (e) a description of an algorithm similar to a computer language

(19)

6.2. Form design and Windows Application Forms in VB

Now a short step-by-step explanation of how to create and run this program using the features of Visual Studio:

Start Visual Studio 2010 from the Start Menu. Once Visual Studio has started, you should see the following screen:

Now, select File->New Project from the menu, and find the entry for creating a new Win32 Form Application

6.3. Coding VB procedures Launching Visual Studio 2010

Action Script Screenshot

Start Visual Studio 2010

• Let’s launch Visual Studio 2010

• One of the first things you may or may not notice is that the VS shell is now written in WPF. This is a very powerful decision and brings forth a lot of potential for very cool features that could not be implemented previously.

• You will also notice a new start page. Once again, this new start page leverages WPF and, hence, is XAML itself. This makes it easily customizable so you can customize it to your own specific needs (perhaps a custom team start page with links to internal coding practices, build servers, etc.)

(20)

Highlight

project(s) in Recent

Projects list

• One of the features afforded to us by the adoption of WPF is easier management of our Recent Projects list for instance.

• Not only can we easily remove projects that we do not wish to be on the list anymore, but I can also pin any projects that I may work on a lot or view as important and wish to keep on the top of my list.

Create a new project by clicking Project ->

New Project on the start page

Expand .NET Framework version drop- down

• First, let’s go ahead and create a new web project

• One feature we want to draw your attention to is multi-targeting.

Similar to previous releases of Visual Studio, you have the choice of targeting different versions of the .NET Framework when developing projects in Visual Studio 2010.

• Multi-targeting allows us to use the latest and greatest tools at our disposal, like Visual Studio 2010, while continuing to be able to develop our current applications against their currently targeted version of the framework.

Create web

project by choose Visual Basic or C# ->

Web ->Empty ASP.NET Web Application

• We’re going to go ahead and create a new Empty ASP.NET web application.

• Let’s just name the project

“HelloWeb” for right now

7.

New Code editing and navigation features

Action Script Screenshot

Right Click in the Project-> Add New Item,

Write Web Form in the search box andname it Page Default.aspx Open Default.aspx, and choose the

• So you’ve seen some simple features that are coming that improve Visual

(21)

Design surface if not chosen already

Open Toolbox, expand “Standard”

Drop a Button and Label onto our page from the Toolbox

Rename Button ->btnSend. Change Button.Text -> “Press Me”

Rename Label ->lblMessage.

Remove value from Label.Text

Studio’s launch- time experience, let’s take a look at some of the new features that will

make a

developer’s life easier with what we do most: deal with code.

• Another useful feature is the ability to search when inserting a new item.

• For the sake of this demo, we will just create a simple Button and Label on a clean default aspx page.

Double-Click our Button in the designer to create a click event handler in code-behind.

In the event handler, type “Mes”

Choose lblMessage from Intellisense and set its Text property to “Clicked!”

• We’re going to go ahead and create an event handler for our Button’s click event

• In the event handler, we are going to simply change the text in our Label.

• You will notice that even though I typed “Mes”, our Labelis still found in Intellisense even though it does not start with

“Mes.” This is because in Visual Studio 2010, Intellisense is much smarter and will search for

“sub-string”

occurrences for

(22)

the text as well, rather than just

“begins with”

occurrences.

• Let’s go ahead and change the text to

“Clicked!”

Highlight the line of code we just wrote.

Extract Method: Right Click -

>Refector -> Extract Method Call the method ChangeText Add a string parameter named

message to the ChangeText method, and pass in “Clicked!”

from the Button’s click event handler.

• We are going to go ahead and use this code again, so we will just refactor this code into a common method called ChangeText.

Press “ctrl+,” (hold down control and press comma) to bring up Quick Search dialog.

Enter “Page” as search item.

Delete “Page” search item and type

“PL” instead.

Press enter to “OK” and accept dialog.

• Another challenge for developers is to be able to navigate around a large code base easily. This becomes much easier in Visual Studio 2010 with the introduction of Quick Search.

• In this case, let’s use it to navigate to our Page_Load method (though this feature is really useful when searching cross- project or cross- file within a solution).

• As you can see, when we enter

“Page”, our method is found as

(23)

expected.

• What isreally cool though, is that Quick Search uses a smart search algorithm that isn’t just substring search. It is fully aware of Pascal

Casing for

instance.

• Let’s search for

“PL” (for

Page_Load) instead. As you can see, our method is still found. When searching for other classes in your project, this becomes a very powerful feature to use for navigation around your codebase.

• Let’s go ahead and accept in order to

open our

Page_Load method.

In the Page_Load method, call our ChangeText to set text to “Not Clicked”

• To add a new default value, we will simply call our new ChangeText method with the value “Not Clicked”

Click the cursor on the name of our ChangeText method.

• Easy visualization of where all references to a method or variable are within a single code file is possible now with the introduction of Highlight

References in the

(24)

editor.

• We’re just going to

click the

ChangeText method, and you can see all references to that

method are

automatically highlighted for us.

Right Click on the name of the ChangeText method ->View Call Hierarchy.

• Another feature that makes it easy to really dig into the relationships between various methods and lines of code is the new Call Hierarchy feature.

• The problem is that trying to understand

external and internal

relationships of a method today requires a lot of digging around the results from “Find All References.”

• Now, by right- clicking on our ChangeText method, we can select “View Call Hierarchy” from the context menu.

• As you can see, we can easily dive into all the various calls that are made to ChangeText as well as all the calls that are made from ChangeText.

• By selecting one of

(25)

the calls either to

or from

ChangeText, we can also see the specific line of code where the call is made.

8.

One-Click Web Deployment

Action Script Screenshot

In the Publish bar, pull down the drop down and click

“<New...>”

• For web developers, a fairly common task is deploying your website to a specific environment (QA, Staging, Live, etc.).

• Unfortunately, robust deployment tools like MS Deploy are only available outside of Visual Studio today.

• With Visual Studio 2010, MSDeployis integrated directly into Visual Studio. Once you have your profiles configured, you can easily deploy to a given environment with a single click.

• This isn’t limited to just MSDeploy either. It also supports other modes of deployment, like via FTP.

• Let’s go ahead and create a new profile for our QA environment.

(26)

Name profile QA by typing “QA”

into the Publish Profile drop down.

Add

http://qa.contoso.com/Hello Web to the Site/Application

Add http://qa-

web:8172/MsDeploy.axd to the Service Url.

Click Save button, and then click Close.

Choose QA from Publish bar drop down, and hover over “Publish Web” button.

• You can see that not only can we specify the method of publishing, we can also specify the site/application, and even mark it as an IIS application on the destination.

• Let’s add some information on our environment to our profile.

• We’re going to go ahead and save this.

• We can know have our QA profile chosen and with one click easily deploy to the designated profile.

• Combining this tool with other new features in Visual Studio 2010 (like web.config transformations) makes for a much more powerful web publishing experience than before.

9.

Visual Studio as a Platform

Action Script Screenshot

Open Windows Explorer

Navigate to “C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\Common Extensions” or C:\Program Files (x86)\Microsoft Visual Studio

10.0\Common7\IDE\Common Extensions”

• A lot of work is going into making Visual Studio a first-class platform, which third parties can “embrace and extend.”

• Part of this effort is making it easier for developers to extend Visual Studio.

• With Visual Studio 2010, creating an editor extension for example is as easy as compiling an assembly and simply dropping it into a specific directory in the Visual Studio installation.

• Next time Visual Studio 2010 is started, it will automatically pick up the new extension.

• While this is simple for developers, it isnot the best experience for end- users.

(27)

Re-Open Visual Studio

Open Tools -> Extension Manager

• To help make the 3rd party ecosystem of Visual Studio much easier to digest, there is a new Extension Manager built into Visual Studio that automatically plugs into the online VS Gallery.

• Using Extension Manager, a Visual Studio user can easily find all sorts of extensions that have been written for Visual Studio, and easily install or uninstall them directly from the Extension Manager itself.

• This gives users the power to customize Visual Studio to best suit their own development needs.

• The extensions are installed under

\Users\{UserName}\AppData\Loc al\Microsoft\VisualStudio\10.0\Ex tensions

9.1. Testing and Debugging

10.

What it involves

References

Related documents

The VX Cycle offers a broad range of scales for the cost-effective production of LNG/CCNG, and the Cycle can be integrated with existing CNG stations, pipeline compressor stations

Since maximal error is located near the cylinder boundary (first order penalization, see fig- ure 12), the cell size for the uniform mesh is equal to the smaller mesh cell for

This document describes how to insert a popup window of the TimeTrade appointment widget while keeping your own web page shaded in the background.. Using this popup widget

Every time the in-memory data structure for a particular column family is dumped to disk we set its bit in the commit log stating that this column family has been successfully

Abiotic (drought, heat, and cold stress) and biotic (pod borers – Helicoverpa armigera and Spodoptera exigua, aphids – Aphis crac- civora, leaf miner – Liriomyza cicerina, and

“In the plan of care for the Medicare payment episode for which this assessment will define a case-mix group, what is the indicated need for therapy visits (total of reasonable

As these results show, a change in the terms of trade has opposite effects on the real wages of male and female workers whether considering the real wage either in terms of

45 In parallel and following the Vienna World Conference on Human Rights, the newly consolidated Office of the United Nations High Commissioner for Human Rights (OHCHR)