Lecture Roger Sutton [email protected] CO331 Visual Programming 1: Module introduction and the...

20
Lecture Roger Sutton [email protected] CO331 Visual Programming 1: Module introduction and the programming environment 1
  • date post

    15-Jan-2016
  • Category

    Documents

  • view

    214
  • download

    0

Transcript of Lecture Roger Sutton [email protected] CO331 Visual Programming 1: Module introduction and the...

Page 1: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

1

Lecture

Roger Sutton [email protected]

CO331 Visual Programming

1: Module introduction and the programming environment

Page 2: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

CO331 Visual Programming 2

Moodle page

To access your module on Moodle go to: http://moodle.kent.ac.uk , log-in and select the required module.

Page 3: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

CO331 Visual Programming 3

Assessment

Coursework 50% Examination 50%The coursework comprises:

1. Class attendance and effort 10%2. In-class test 20%3. Programming assignment 1:

‘Using a given class’ 25%4. Programming assignment 2:

‘Writing and using classes 25%5. In-class on-line multiple choice test 20%

2 hr closed-book written examination.This module is non-compensatable – you must obtain at least 40% overall in this module to progress to Stage 2.

Page 4: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

CO331 Visual Programming 4

Logbooks

It is strongly recommended that you keep an A4 bound log/note book (A separate one for different modules. Similar to a laboratory note book)Every time you do any work/activity related to the module, make a record.

1. Each entry should be dated2. Start, possibly, by indicating what is to be achieved during

the session, or the purpose of meeting, etc.3. Indicate any relevant references, data sources4. Record salient points of meeting discussions, agreed

decisions and actions

Page 5: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

5CO331 Visual Programming

Logbooks - cont’d

5. Record any design decisions or revisions and the reasons why these are considered necessary

6. Record any failed prototyping, the cause and any conclusions

7. Indicate what has been achieved and/or still outstanding8. Indicate the duration of the session

This should not resemble so much a diary but more a jotting pad that records in one place all activities, significant thoughts, attempts and failures relating to your work.

Page 6: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

CO331 Visual Programming 6

Object Oriented Programming

“All the world’s a stage,

And all the men and women merely players;                 

They all have their exits and their entrances,

And one man in his time plays many parts,”

As you like it, W Shakespeare

Page 7: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

7CO331 Visual Programming

OOP – cont’d

A computer program is an attempt to represent some aspect of the world. Not all of the world but just a small part of interest – the problem domain. Thus a computer program can be thought of as a model.The model will have various components or actors that interact with each other to simulate the behaviour of the problem domain. Accordingly the model will change.In programming the components of the model are called objects and we shall be concerned with manipulating these objects – hence the term: Object Oriented Programming (OOP).

Page 8: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

CO331 Visual Programming 8

Programming environment

Most programming is now performed with aid of a software development tool. This is sometimes referred to as an IDE or integrated development environment. This provides the means to write, edit and compile code, and run and debug programs.

We shall create Visual Basic programs within an environment called Visual Studio.

Page 9: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

CO331 Visual Programming 9

Program Development Environment – cont’dWhen Visual Studio is first opened, it displays a dialog where you select the required developer tool from the profile list, i.e. Visual Basic.Net. It then displays the Start Page.At this point it is recommended that Tools/Options is used to indicated the default folder in which to store VB projects.

I suggest you create a folder called progs within your co331 folder, then use the browse button to navigate to this folder to enter location address.

Page 10: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

CO331 Visual Programming 10

Create new project

i Click on the New Project link on the Start Page, or icon.

i Select Windows Forms Application and give project a name, say co331Welcome.

i Ok.

Page 11: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

CO331 Visual Programming

Environment – cont’d

The design view of the IDE is then opened. This comprises several windows, a menu bar and tool bar:

Page 12: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

12CO331 Visual Programming

Environment windows

• Form1.vb [Design] window contains a form, Form1, where the program’s graphical user interface (GUI) will be constructed. This will be used for data entry and output.

• Properties – Form1 records/displays the form’s properties, e.g. colour, font style, size, etc. These are listed alphabetically or categorically depending on the tab selected

Page 13: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

13CO331 Visual Programming

Environment windows – cont’d• Solution Explorer – co331Welcome. This window groups the project’s files by type. Usually

referred to as ‘the Solution window’, it has buttons to:■ View code – displays a window for writing VB code■ View Designer – displays the form in design view■ Show all files – lists all files in the current project

Page 14: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

14CO331 Visual Programming

Environment windows – cont’dThe Toolbox contains controls used to customise forms. Controls are pre-packaged components that may be incorporated into forms and allow programs to be created more quickly.

Page 15: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

15CO331 Visual Programming

A simple program

- to display the text “Welcome to Visual basic” on a form.

1. Create New Project called co331Welcome and open the IDE in design view.If necessary click the Form design icon to reveal Form1 in design view

2. In the properties window:Set the form’s title bar – opposite Text enter:Lecture1: A simple program

Page 16: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

16CO331 Visual Programming

A simple program – cont’dEnsure that the form “has the focus” by clicking on the form then3. Change the form’s background colour, BackColor - choose a light colour from custom palette4. Set the form’s default font to Arial, bold, 14pt. 5. Set the font colour, forecolor, to a

dark colour

Page 17: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

17CO331 Visual Programming

A simple program – cont’dIf not already open, click on the Toolbox icon and then the drawing pin symbol so that it remains open. If necessary, click Common Controls within the Toolbox.6. Add a label control to the form:

Click and drag the toolbox label control to the form and position it using the sizing handles.

7. To set the label display:Type the required text: Welcome to Visual Basic! in the label’s Text property.

Page 18: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

18CO331 Visual Programming

A simple program – cont’d

Reposition the label on the form using the handler (top left of label). Note the change of values in the Location property.

Page 19: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

19CO331 Visual Programming

A simple program – cont’dIn Design view an Output window may be made visible:

View|Other Windows|OutputWhen the program is run this windows will report any errors detected.To run the program click the Start icon on the menu bar.

The program is terminated by closing the form window.Click the close dialog icon.

Page 20: Lecture Roger Sutton c.r.sutton@kent.ac.uk CO331 Visual Programming 1: Module introduction and the programming environment 1.

20CO331 Visual Programming

Summary

• Moodle page• Assessment• Logbooks• Object oriented programming• Visual Studio environment• Environment windows• Visual programming – controls and properties