Introduction%20to%20Computer%20Programming%20IT-104 - PowerPoint PPT Presentation

View by Category
About This Presentation
Title:

Introduction%20to%20Computer%20Programming%20IT-104

Description:

This will start the Visual Basic IDE (Integrated Development Environment) ... BASIC was yet another new language, and its simplicity and utility made it a ... – PowerPoint PPT presentation

Number of Views:460
Avg rating:3.0/5.0
Slides: 89
Provided by: ITt87
Learn more at: http://www.afn.org
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Introduction%20to%20Computer%20Programming%20IT-104


1
Lab
MIS
Six Ops
Programs
Languages
Methods
Properties
Events
VB IDE
OOED
Simple Calc
Exit
  • Introduction to Computer Programming IT-104
  • Unit One - An Overview of the Visual Basic IDE
    and the Visual Basic Form

2
Objectives
  • Discuss and understand the rules and procedures
    that will be used in the computer labs at ITT
    Tech.
  • Discuss and understand the course syllabus and
    objectives.
  • Discuss and understand the course grading and
    assignments.

3
Objectives
  • Understand the importance of information systems
    in organizations.
  • Discuss the role of computer programs and
    programming in information systems.
  • List and discuss the six computer operations.
  • Describe the difference between modern
    Windows-based computer languages

4
Objectives
  • and older procedural languages.
  • Discuss the difference between compiled and
    interpreted languages.
  • List and discuss the steps in the
    object-oriented, event-driven programming
    process.
  • Discuss the Visual Basic form, how to work with
    the Visual Basic IDE

5
Lab Procedures
  • The instructor will open the cabinets containing
    the removable hard drives.
  • Notice that each one is labeled with a unique
    tag.
  • Take the hard drive to the machine with the
    matching tag.
  • Use both hands, carry NOTHING ELSE,

6
Lab Procedures
  • if you drop the drive, it will be permanently
    damaged, and you will be responsible for its
    replacement.
  • The drive must be inserted into the machine with
    the label right-side up.
  • Do not force the drive, it should slide in
    easily. If not, consult your instructor.

7
Lab Procedures
  • You must now lock the drive in place with one of
    the drive keys. This prevents the drive from
    falling out, and also completes the electrical
    circuit within the computer.
  • You may now turn on the computer.
  • If a DOS type text screen appears and asks you to
    press F1 (in the lower left hand corner), then
    do so.

8
Lab Procedures
  • You should now receive a Windows NT boot screen,
    giving you several choices of operating systems
    to boot.
  • Choose Windows NT 4.0 (It should be the default
    choice) by pressing the Enter key.
  • After Windows NT boots, select Start from the
    taskbar.

9
Lab Procedures
  • Select Programs, then IT, then Visual Basic
    6.0.
  • This will start the Visual Basic IDE (Integrated
    Development Environment).
  • At this point, you should be ready to begin
    working with Visual Basic.

10
History of Programming Languages
  • The first computers (ENIAC was such a machine)
    were vacuum-tube devices, and they were quite
    primitive by todays standards. Programming
    these machines consisted of technicians climbing
    about on the machine itself and throwing various
    switches in the proper sequence, at the proper
    time.

11
History of Programming Languages
  • As computers evolved into transistor solid state
    devices, improved methods could be developed to
    program them, and the notion of the computer
    program evolved.
  • A program is nothing more than a logical sequence
    of instructions to a machine to accomplish a
    specific task.

12
History of Programming Languages
  • It is generally agreed that the first major
    language for computers was FORTRAN (an acronym
    for FORmula TRANslating system), which was
    developed by the IBM corporation around 1957.
  • Following FORTRANs introduction closely was LISP
    in 1958, which was developed by John McCarthy of
    MIT.

13
History of Programming Languages
  • In the late 50s, as the importance of the
    computer became increasingly clear, and
    organizations began to depend upon it, the U.S.
    government undertook a project to develop a
    language that was more user-friendly to modeling
    and processing business systems. The result was
    COBOL (an acronym for the COmmon Business

14
History of Programming Languages
  • Oriented Language). COBOL dominated computing
    for the next 30 years, but like FORTRAN and its
    contemporaries, it suffered from a number of
    deficiencies. The most important of these
    deficiencies was the inability to write truly
    portable code, and the difficulty in reusing code
    modules (or procedures)

15
History of Programming Languages
  • In the early 70s, Dennis Ritchie, who developed
    the UNIX operating system along with his
    colleagues at Bell Labs, created a new
    programming language to use with the new OS. His
    language was derived from an existing computer
    language known simply as B. Ritchie decided
    jocularly to name his language

16
History of Programming Languages
  • C and the name stuck.
  • C is a function oriented language, that is, great
    care is given to carefully analyzing the program
    to be written, and then breaking it down to its
    simplest component parts. Each of these parts
    then has a function written for it. Functions
    may be used and reused within

17
History of Programming Languages
  • C program.
  • C became quite popular, and it is still widely
    used, but it has difficulty in dealing with
    Objects and other mathematical abstractions.
  • To address these shortcomings, Dr. Bjarne
    Stroustroup took the C language

18
History of Programming Languages
  • and added the necessary extensions to implement
    the Class concept and make C a fully
    object-oriented language. He called his language
    C, and this language is the choice of software
    developers today world-wide.
  • Also in the 70s as Bill Gates rose to prominence
    in the computing world,

19
History of Programming Languages
  • he is generally given credit for developing
    BASIC(the Beginners All-purpose Symbolic
    Instruction Code).
  • BASIC was yet another new language, and its
    simplicity and utility made it a popular choice
    with neophyte programmers of all ages.

20
History of Programming Languages
  • In the early 80s, as Graphical User Interfaces
    (GUIs) began to catch on with computer users, the
    Microsoft corporation took the BASIC language and
    ported it to the Windows environment, and Visual
    Basic was the result. The current version we are
    using is version 6.0, and a new version Visual
    Basic.NET has just been

21
History of Programming Languages
  • released by microsoft.
  • There are hundreds of other programming
    languages too numerous to list here, each
    created by someone to serve a specific purpose.
    The experienced programmer is aware of this and
    he will choose the appropriate language for the
    task at hand.

22
Information Systems in Business
  • An information system is the combination of
    technology (computers) and people that enables an
    organization to collect data, store them, and
    transform then into information.
  • Data are raw facts that are collected and stored
    by the information system. Data can be in any
    form that can be digitized.
  • Information is created when data are organized
    into a meaningful form.

23
Information Systems in Business
  • Software is composed of one or more lists of
    instructions called programs, and the process of
    creating these lists of instructions is called
    programming. Software is required to convert or
    process data, and to enable the computer to
    communicate and coordinate all the various
    devices required to perform its functions.
  • The business climate has changed drastically in
    the past 25 years, so that now virtually any
    business having more than a couple of employees
    is dependent on the computer as a tool to store,
    process, and retrieve business related
    information.

24
The Six Computer Operations
  • Input data
  • Store data in internal memory
  • Perform arithmetic on data
  • Compare two values and select one of two
    alternative actions
  • Repeat a group of actions any number of times
  • Output the results of processing

25
The Six Computer Operations
  • Input data - Data may be entered from the
    keyboard, using a mouse, using a scanner, a
    microphone, or any input device. Traditional
    mainframe programs use disk drives or magnetic
    tape drives to input data stored during business
    operations for later processing during scheduled
    batch processing or for on-demand processing by
    users.

26
The Six Computer Operations
  • Store Data in internal memory - Data entered into
    a program must be stored either completely or
    partially in the computers main memory banks for
    later use by the various programs used to
    manipulate the data.

27
The Six Computer Operations
  • Perform arithmetic on data - This is the most
    common use most people think about when the word
    computer is mentioned. A computer can perform
    any mathematical calculation on numerical data
    that a human can do, and the computer can do it
    far more quickly, accurately, and consistently
    than the most conscientious and careful human.

28
The Six Computer Operations
  • Compare two values and select one of two
    alternative actions - This is a very important
    concept that is often overlooked in discussing
    computer operations. A computer can compare two
    data items, whether or not they are numeric, and
    take some action based on whether or not the two
    data items are identical.

29
The Six Computer Operations
  • Repeat a group of actions a number of times -
    Another often overlooked function of computers is
    that they can perform tedious, repetitive
    operations, such as reading in the contents of a
    multi-million record file, counting very high or
    very small numbers, using various loop
    structures, which we will discuss in coming weeks.

30
The Six Computer Operations
  • Output the results of processing - After data has
    been manipulated or processed, the results can
    then be displayed on a video display terminal, or
    sent to a printer, or stored on any number of
    magnetic or optical storage media, or the output
    can be directed to any other legitimate output
    device such as a loud speaker, as in the case of
    a music editing program.

31
Programs and Programming
  • Logic is a step-by-step process that will solve a
    problem. A logical process of this type is known
    as an algorithm.
  • All programming is simply applied problem
    solving, utilizing the tools at the disposal of
    the programmer.
  • Lets take a look at a simple algorithm that we
    all learned in primary school. The
    multiplication algorithm enables us to multiply
    numbers having more than one digit per number.

32
Programs and Programming
  • A Simple Algorithm (from primary school)
  • 3457
  • x 117
  • 24199
  • 3457
  • 3457
  • 404469

33
Programming Languages
  • Low level languages
  • Machine language - the binary language of the
    computer (zeros and ones)
  • Assembly language - one step up, uses simple
    mnemonics to facilitate usage and understanding
  • Mid-level languages
  • C - a function-based language, employs the

34
Programming Languages
  • power of pointers
  • C - a superset of C, introduced the concept of
    objects to programming
  • High level languages
  • COBOL - Developed for use by businesses
  • Fortran - Developed for use by science and
    engineering
  • Visual Basic - all are english-like languages,
    easy to read and comprehend.

35
Programming Languages
  • Machine language program example - will run as
    you see it.
  • 0001 00101010 11100110
  • 0101 00010010 11110111
  • 0111 10010001 11110110
  • 0010 01100101 01011011
  • 1010 11011011 01011010
  • 0101 10000001 01001100

The spaces and lines have been added here for
ease of reading only. They wouldnt exist in a
real file.
36
Programming Languages
  • Assembly language example - must be compiled
    first.
  • Include windows.inc
  • .model tiny
  • load reg1, 01011011 91 into arithmetic
    register one
  • load reg2, 00001010 10 into arithmetic
    register two
  • add reg1,reg2 add register one to register
    two
  • movr reg2,reg3 move register two to three
  • snd addr, 0100010101 send results to output
    window

37
Programming Languages
  • C language example - must be compiled first.
  • // Add.cpp - Program to add two numbers together
  • include ltiostream.hgt
  • int main()
  • int num_one(74), num_two(28)
  • cout ltlt The sum of the two numbers is
  • ltlt num_one num_two ltlt endl
  • return 0

38
Programming Languages
  • Visual Basic language example - must be compiled
    or interpreted
  • Public Sub cmdAdd_click()
  • dim FirstNumber as integer, SecondNumber as
    integer
  • dim Result as integer
  • FirstNumber txtFirstNumber
  • SecondNumber txtSecondNumber
  • Result FirstNumber SecondNumber
  • txtResult Result
  • End Sub

39
Programming Languages
  • A computer program must either be compiled or
    interpreted.
  • An interpreter converts the high level language
    statements into machine code, one at a time, as
    the program is executed.
  • A compiler converts the entire program into
    machine code, and then links it with various
    other necessary files to produce an executable
    file or program. This finished program can be

40
Programming Languages
  • run or executed by simply typing its name at a
    command line, or by selecting its icon in a
    windows environment.
  • The original program file or source code, is no
    longer recognizable when the executable program
    is opened using any text editor as you can see in
    the next slide.

41
A Sample Executable Program
This is the language the computer understands.
The file contains mostly non-display characters
that give unusual characters you see here
whenever you try to display them with a text
editor.
42
A Typical Compiler Implementation
Translates our English-like commands and
statements into machine language, which is the
only language that the computer can understand.
43
Programming Methods
  • There are essentially two different methods of
    programming.
  • Procedural programming - was and still is used on
  • mainframe computers, as well as on most command
    line based operating systems. These programs run
    from start to finish with no intervention from
    the user other than input. Typically submitted
    by typing a command at a command line, or by
    clicking an icon if the program operates within a
    Graphical User Interface.

44
Programming Methods
  • Event-driven programming(OOED) - adopted for the
    windows and windows-style operating systems.
  • An event is something that the operating system
    is aware of, and it can react to the event. A
    mouse click, or pressing a key on the keyboard
    are examples of events.
  • Object-Oriented Event-Driven programming uses
    objects, or self-contained modules that combine
    data and program code which pass strictly defined
    messages to one another.
  • OOED is easier to work with, because it is more
    intuitive than traditional programming methods.
  • Visual Basic is an OOED language.

45
Programming Methods
  • Visual Basic comes with several hundred controls
    provided by Microsoft, and each of these controls
    has some number of defined events (by Microsoft)
    and experienced programmers can create and code
    their own events, if needed.
  • Object-oriented languages use identifiable shapes
    or structures.
  • Each object has a set of properties associated
    it. Programmers must learn to use these
    properties to properly manipulate and use the
    object itself.

46
Programming Methods
  • Each object has a set of methods associated with
    it that the object can carry out. Methods are
    simply executable code that is written for and
    stored with the object.
  • Each object can respond to specific set of
    events.
  • The events that an object can respond to will
    vary with what the object was designed by the
    programmer to do.

47
Programming Basics
  • The Basic foundation within Visual Basic is the
    Form. When you start Visual Basic, you will
    usually have a default form (form1), and a
    default project (project1).
  • The Form is our first example of an object.
  • Let us examine the form and discuss the
    properties associated with the Form.
  • The Form in Visual Basic has a set of 51
    properties associated with it.

48
Properties and Objects
  • By changing the settings of these properties, we
    can change the behavior of the form.
  • Some of the properties are simple switches, that
    is they are either true or false, off or on. The
    Visible property is an example of such a
    property.
  • Other properties have integer values associated
    with them. For example, the BorderStyle property
    has six integer values (0 to 5) that can

49
Properties and Objects
  • be chosen when the form is created.
  • Still other properties may have numbers
    associated with them, such as the Height and
    Width properties of the form.
  • Finally, some properties have string values
    associated with them. The Name property is
    typically a string value.
  • The settings of properties help to determine

50
Properties and Objects
  • how an object will respond to various events
    within the operating system and program.

51
Events
  • The Form has a set of 31 events that it can
    respond to. The following events are the most
    common.
  • Activate - This event occurs when a form gets the
    focus. If a project has multiple forms, the
    Activate event occurs whenever the use changes to
    a different form by clicking the form or by
    select the form from a menu.
  • Click - This event occurs when the user clicks
    anywhere on the form. If the user clicks a form

52
Events
  • thats partially hidden from view because
    another form has the focus, both a Click and an
    Activate event take place.
  • DblClick - This event occurs when the user
    double-clicks the form.
  • Deactivate - This event occurs when another form
    gets and focus. Therefore, both the Activate and
    Deactivate events occur when the user selects a
    different form. You may choose to write event
    procedures for both events for each form, for
    only one event for one of the forms, or a
    combination

53
Events
  • thereof, depending on the needs of your
    application.
  • Initialize - This event occurs when the form is
    first generated.
  • Load - This event occurs right as the form is
    loaded into active memory and appears on the
    screen. This event occurs only once per form
    during an applications execution.
  • Paint - This event occurs when Window must redraw
    the form because the user uncovered part of the
    form from under another object, such as an icon.

54
Events
  • Resize - This event occurs when the user changes
    the size of the form.
  • Unload - This event occurs when the application
    removes a form from the window using code. When
    an application is terminated, all loaded forms
    are first unloaded, so you must write an Unload
    event procedure for each form if you want to
    perform some kind of clean-up or file-saving
    procedure at the end of an applications session.

55
The Visual Basic IDE
  • The next slide shows the Visual Basic Integrated
    Development Environment. Virtually all
    programming software today now incorporates an
    IDE in its implementation. This format greatly
    facilitates and speeds up the development and
    coding of Windows or other OOUI operating systems
    programs or applications.

56
Menu Bar
Standard Toolbar
Project Explorer window
Properties Window
Form Window
Tool Box
Form Layout Window
57
Visual Basic Menu Bar
58
Visual Basic Tool Box
59
Project Explorer Window
View code
View Object
Change Folders
Used to select the code or object or to change
folders.
60
The Properties Window
Window Name
Object Box
Properties List Tabs
Scrollable list of properties
Description Pane
Used to change the properties of controls at
design time.
61
Design Time and Run Time
  • You are in Design Time when you are creating
    and modifying the project and adding code
  • You are in Run Time when you click the VCR Run
    icon and the VB program is being executed
  • You can stop the project and exit Run time by
    clicking the VCR Stop Icon.
  • You can go to Break Mode by clicking the VCR
    Pause Icon.

62
A Sample Code Window
  • The previous slide showed the object-view of a VB
    form. This is where the programmer places the
    objects(controls) needed for his application.
  • The next slide will show you the code-view of a
    VB form. This is where the necessary program
    code to make the controls behave in a specific
    manner is typed.

63
The location of the cursor in the code window
determines which procedure is being edited
The code window acts like a word processor for
your procedures
Lines separate event procedures
64
OOED Programming Process
  • A six step process for writing an OOED computer
    program
  • 1. Define the problem.
  • 2. Create the interface.
  • 3. Develop the logic for action objects.
  • 4. Write and test the code for action objects.
  • 5. Test the overall project.
  • 6. Document the project in writing.

65
OOED Programming Process
  • Remember an Object-Oriented Event-Driven
    programming language uses objects with properties
    and methods, and it responds to events. If you
    can understand this process, you will have
    mastered the concepts behind the OOED IDE
    programming environment and process.

66
OOED Programming Process
  • Step One Define Problem
  • Before you can create a computer application to
    solve a problem, you must first clearly define
    the problem.
  • This may involve a study of the problem to
    understand the inputs and outputs.
  • You must identify the data to be input to the
    program and the results to be output from it.

67
OOED Programming Process
  • Sketching an interface is frequently a good way
    to understand the problem and to communicate your
    understanding to other people. (A picture is
    really worth a thousand words.)
  • Denote input and output objects as well as action
    objects, as well as action objects--those for
    which code (instructions) are needed.

68
OOED Programming Process
  • Lets now apply this process to creating a
    simple calculator that takes two numbers and adds
    them together. The numbers will be entered from
    the computer keyboard, and the sum of the two
    numbers will be displayed in a label on the
    calculator form. But first we need to talk about
    IPO tables and PseudoCode.

69
IPO Tables
  • Input/Processing/Output tables are tools for
    developing your application after you have done
    some preliminary analysis. To develop an IPO
    table, you need to list all of the program
    inputs, any processing that is done to these
    inputs, and then list the resulting outputs of
    the program.

70
IPO Tables
71
PseudoCode
  • Pseudocode is a technique to help programmers
    code a form or application.
  • The problem is analyzed, and the proposed
    solution is written in natural english, without
    regard to the syntax of any particular
    programming language.

72
A Simple Calculator
  • Step One - Define the problem.
  • Create a simple calculator that adds two numbers
    together. The numbers must either be entered
    from the keyboard or selected from a control
    using the mouse. Since this is a beginning
    project, we will use the keyboard to simplify our
    analysis and writing the code for our objects.

73
A Simple Calculator
  • Step Two - Create the interface.
  • The interface for our proposed calculator might
    look like the form on the following slide. This
    is by no means the only way to lay out the form.
    How the form is laid out is, within certain
    parameters, a matter of personal taste.

74
A Simple Calculator
75
A Simple Calculator
  • Step Three - Develop logic for the action
    objects.
  • For our simple calculator, there will be three
    action objects three command buttons.
  • cmdCalculate - will add the numbers entered into
    the two text boxes.
  • CmdClear - will clear the text boxes and label so
    that the calculator can be used repeatedly.
  • cmdExit - closes the program.

76
A Simple Calculator
  • The IPO table for our calculator might look like
    the following
  • Input Processing Output
  • txtFirstNum assign FirstNum(a variable)
  • txtSecondNum assign SecondNum(variable)
  • cmdCalc add FirstNum to Sum(variable)
  • SecondNum
  • assign Sum to lblSum
  • cmdClear clear boxes/labels all display
  • cmdExit exit the program none

77
A Simple Calculator
  • Again, a reminder, the purpose of IPO tables is
    to help structure your program. In conjunction
    with a preliminary sketch and pseudocode, the IPO
    table will help you create and code your form.
    It is an invaluable tool for helping you name(and
    then remember the name) your objects.

78
A Simple Calculator
  • The pseudocode for our calculator might look like
    the following
  • cmdCalculate (The Calculate Button)
  • Begin Procedure
  • Get the data in the first text box.
  • If the first text box is empty, then
  • End the procedure.
  • End of If.
  • Load data from first text box into a variable.

79
A Simple Calculator
  • cmdCalculate (The Calculate Button)
  • Get the data from the second text box.
  • If the second text box is empty, then
  • End the procedure.
  • End of If.
  • Load data from second text box into a variable.
  • Add the two variables together and store the
    result
  • in a third variable.

80
PseudoCode
  • cmdCalculate - (Continued)
  • Display the third variable in a text box or a
    label.
  • cmdClear (The Clear Button)
  • Clear the data in the first text box.
  • clear the data in the second text box.
  • Clear the data in the third text box or label.
  • Place the cursor in the first text box so that
    the program is ready to receive input from the
    user.

81
PseudoCode
  • cmdExit (The Exit Button)
  • Clear all variables and return the vacated memory
    to the operating system.
  • Clear the form from the screen and return that
    memory to the operating system.
  • Return an exit code to the operating system. (The
    exit code tells the operating system whether or
    not the program terminated normally.)

82
Summary
  • Discuss and understand the rules and procedures
    that will be used in the computer labs at ITT
    Tech.
  • Discuss and understand the course syllabus and
    objectives.
  • Discuss and understand the course grading and
    assignments.

83
Summary
  • Understand the importance of information
    systems in organizations.
  • Discuss the role of computer programs and
    programming in information systems.
  • List and discuss the six computer operations.
  • Describe the difference between modern
    Windows-based computer languages

84
Summary
  • and older procedural languages.
  • Discuss the difference between compiled and
    interpreted languages.
  • List and discuss the steps in the
    object-oriented, event-driven programming
    process.
  • Discuss the Visual Basic form, and how to work
    with the Visual Basic IDE.

85
LAB Work
  • Create a simple form, name and save it and the
    associated project.
  • Using this form, add two text boxes, an output
    label, three command buttons, and any other
    visual enhancements you consider appropriate to
    create a simple calculator. Name your form and
    project Simple Calculator.

86
LAB Work
  • Create and save a form and its associated
    project. This form will have three labels, one
    text box, and three command buttons, as well as
    any other visually enhancements that you wish.
    Name your form Simple Program.

87
Assignment
  • Read Chapters 1, 2, and 3
  • Create IPO charts for the problem assigned in
    lab.
  • Create the form only for the same problem. You
    are not required to do any coding for this
    problem at this time.

88
Next Week
  • Remember to bring a diskette(s) to class with you
    next time.
  • More working with the Visual Basic IDE.
  • Creating your first project.
  • Quiz over Unit One material.
About PowerShow.com