Professional Documents
Culture Documents
Week 2 - Lecture 1: Objects and Classes
Week 2 - Lecture 1: Objects and Classes
NET
Week 2 – Lecture 1
© Angela Carbone
Monash University
School of Information Management and Systems
www.monash.edu.au
Lecture Outline
www.monash.edu.au
2
What are Objects?
An Object:
• Has a unique identity
• An object has properties (or attributes) which
distinguish it from other objects and others of
its class – the object’s data
• Has methods (or procedures) which enable it to
respond to external events – allow it to interact
with other objects, the system, and the user
• Is an instance (example) of a class
www.monash.edu.au
3
Object – General Example
www.monash.edu.au
5
Attributes or Properties
www.monash.edu.au
6
Operations or Methods or behaviour
www.monash.edu.au
7
What are Events?
www.monash.edu.au
8
Event-Driven Programming
www.monash.edu.au
9
VB .NET Programming
www.monash.edu.au
10
Some Visual Basic .NET Graphic Objects
• Text box
• List box
• Label
• Button
• Option Button
• Check box
• Forms
www.monash.edu.au
11
Some Properties of VB.NET Objects
www.monash.edu.au
12
VB.NET Object Properties
www.monash.edu.au
13
Properties are assigned by ...
• Properties Window
– Click object with mouse – updates RHS
panel
– If not visible, press ‘F4’
• Code associated with an event
– Typed in the code-window
– e.g. Text1.Visible = True
– e.g. Button1.Enabled = False
www.monash.edu.au
14
Getting Started with VB.NET
www.monash.edu.au
15
Visual Studio .NET - Start Page
Solution
Explorer
Recent Projects
Dynamic
Toolbox Help
Name of
Name and Location Project
Of Project
www.monash.edu.au
17
The Visual Studio .NET Environment
• Form designer
– Design screens
– Toolbar
• Code Editor
– Specify/Implement code
• Property-Editor window
– Change design attributes of the objects on a form
• Solution Explorer
– Shows the Projects and Forms in an application
www.monash.edu.au
18
Starting a New Project
• We will be creating Windows Applications
• They will be Visual Basic Projects
– Project Files (.vbproj)
> a document that contains references to all project items such
as forms and classes in addition to project references and
compilation options.
• The project will be part of a Visual Studio.NET
Solution
– Solution Files (.sln, .suo)
> The .sln extension is used for solution files that link one or more
projects together, and are also used for storing global
information.
> The .suo file extension is used for Solution User Options files
that accompany any solution records and any customisations
you make to your solution.
www.monash.edu.au
19
Solution Explorer Window
www.monash.edu.au
20
Reading/Questions
www.monash.edu.au
21
IMS1906 Programming in VB.NET
Week 2 – Lecture 2
Introducing VB.NET
© Angela Carbone
Monash University
School of Information Management and Systems
www.monash.edu.au
Lecture Outline
• VB.NET IDE
• VB.NET objects
• Writing VB.NET code
www.monash.edu.au
23
VB.NET
www.monash.edu.au
24
VB.NET / Integrated Development Environment contd.
– Toolbox window
> contains set of controls which make up a VB application.
– Windows Form designer window
> central part of VB. It provides the display area for the
application acts as a container for all the controls
– Properties window
> Each object in VB has a set of characteristics called
properties. This window contains the properties that control
the object’s appearance and behaviour.
> Object box, Properties list, Description pane, settings box
– Main window
> At top of screen. Contains
– title bar:
– menu bar: displays commands used to build VB application
– standard tool bar: quick access to commonly used menu commands
www.monash.edu.au
25
www.monash.edu.au
26
Working with objects/controls
www.monash.edu.au
27
Form Control
www.monash.edu.au
28
Label control
www.monash.edu.au
29
PictureBox Control
www.monash.edu.au
30
Text Box Control
www.monash.edu.au
31
Button Control
www.monash.edu.au
32
Access Keys
• Example of objects
– Form, pictureBox, label, command buttons
• Example of events (user actions)
– click, double click, scroll, keypress
• Event procedure (method)
– VB.NET instruction, or code that tells an
object how to respond to an event
www.monash.edu.au
34
Starting and Ending an Application
• To run an application
– Click Debug then click start or press F5
– Visual Studio .NET creates an executeable
file(.exe) that can be run outside the IDE
– Demo:
> Lets run our application. What happens?
www.monash.edu.au
35
The VB.NET Code Editor Window
www.monash.edu.au
38
VB.NET Form – Class Definition
Name of
Start of a Object
Procedure
Event to
respond to
Assignment statement -
End of a Procedure Changes the ‘text’ property
www.monash.edu.au
41
Writing Visual Basic .NET Code
• Me.Close( ) Method
– Terminates the current application
– The Me in the instruction refers to the
current form
– The Close is the method
www.monash.edu.au
44
Is VB.NET Interpreted or Compiled?
– Got that?
www.monash.edu.au
45
End - Today we covered
www.monash.edu.au
46
Reading/Questions
www.monash.edu.au
47