SlideShare a Scribd company logo
aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf
Introduction to Visual Basic.NET 2005 Chapter 1 McGraw-Hill © 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Chapter Objectives  (1 of 2) Describe the process of visual program design and development Explain the term object-oriented programming Explain the concepts of  classes ,  objects ,  properties ,  methods , and  events List and describe the three steps for writing a Visual Basic project Describe the various files that make up a Visual Basic project
Chapter Objectives  (2 of 2) Identify the elements in the  Visual Studio environment Define  design time ,  run time , and debug time Write, run, save, print, and modify your first Visual Basic project Identify  syntax errors ,  run-time errors , and logic errors Use Auto Correct to correct syntax errors Look up Visual Basic topic in  Help
Writing Windows Applications with VB (1 of 2) Windows  Graphical User (GUI)  Interface Defines how elements look and function
Writing Windows Applications with VB (2 of 2) Elements are called  controls  and are added using a toolbox Windows are called  forms
Programming Languages-Procedural, Event Driven and Object Oriented Procedural —Cobol, Fortran, Basic Program specifies exact sequence of all operations Event  Driven (VB 6.0 and previous) Contain some elements of Object oriented programming but not all Object Oriented Programming (OOP)  (VB .NET) User controls sequence Click event Double Click event Change event
The Object Model   (1 of 2) In VB you will work with objects, which have properties, methods, and events. Each object is based on a class. Objects  equate to Nouns Forms  are windows Controls  are components contained inside a form Properties  equate to Adjectives Color or size of a Form Methods  are like Verbs Typical methods include Close, Show and Clear
Object Model   (2 of 2) Events occur when the user takes action User clicks a  button , User moves a form Classes  are templates used to create a new object Classes contain the definition of all available properties, methods, and events Each new object created is based on a class Creating three new buttons makes each button a instance of the Button class
Object Model Analogy Class = automobile Properties = make, model, color, year Object = each individual car Object is also an Instance of the automobile class Methods = start, stop, speedup, slowdown Events = car arrives, car crashes
Visual Studio .NET   Included in Visual Studio .NET 2005 Visual Basic (can also be purchased separately) Visual C++ C# (C sharp) J# (J sharp) .NET 2.0 Framework Visual Studio .NET Editions Standard Professional Enterprise Developer Enterprise Architect
Writing Visual Basic Projects There is a three-step process when writing a Visual Basic application—you set up the  user interface , define the properties and then create the  code Planning Design the User Interface Plan the Properties Plan the Basic Code; follow the language  syntax  rules; use  pseudocode  (English expression or comment describing action) then you move on to Programming (and use the same three step process) Define the User Interface  Set the properties Write the Basic code
VB Application Files One Solution File—think of one  solution file  equals one project .sln Solution User Options File .suo Form Files .vb Resource File for the Form .resx Project Files .vbproj Project User Options File .vbproj.user Application configuration File .app.config Once a project is run several more files are created by the system. The only file that is opened directly is the solution file.
Visual Studio Environment The Visual Studio environment is where you create and test your projects-in Visual Studio it is called an Integrated Development Environment  (IDE)  consists of various tools including: Form Designer Editor for entering code Compiler Debugger Object Browser Help  facility
Default Environment Settings Visual Studio 2005 provides a new option that allows the programmer to select the default profile for the IDE
The IDE Initial Screen The Visual Studio IDE with the Start Page open, as it first appears in Windows XP, without an open project.
IDE Main Window Toolbars Document Window Form Designer Solution Explorer Window   Properties Window Toolbox  Help
ToolBox Y ou can scroll to view more controls  To sort the tools in the toolbox: Right-click the toolbox and select Sort Items Alphabetically   from the  context menu  (shortcut menu).
Modes Design Time--used when designing the user interface and writing code Run Time--used when testing and running a project Break Time- -if/when receiving a run-time error or pause error “ Look at the Title Bar”
Writing Your First Visual Basic Project Setting Up the Project 1 2 3 Hello World Project
Planning the Project Design the user interface Set up the form Resize the form Place a  label  and a button  control on the form using the  toolbox Lock the Controls in place After the user interface is  designed, the next step is to  set the properties
Setting Properties Label 1 Name  messageLabel Text leave blank Button 1 Name pushButton Text Push Me Button 2 Name exitButton Text Exit Form Name helloForm Text Hello World by  your name
Setting the Form Properties The default startup object is Form1 The name of the form should always be changed to adhere to naming rules The properties window shows the files properties
Writing the Code While the project is running the user can perform actions Each action by the user causes an  event  to occur Write code for the events you care about; the events you want to respond to with code Code is written as  event   procedures VB will ignore events for which you do not write code VB will automatically name event procedures as the object name, an underscore(_) and the name of the event
More on Writing the Code When writing the code for your first project you will use the following: Remark Statement Assignment Statement Ending a Program Editor Window
Remark Statement Also known as Comment, used for documentation; every procedure should begin with a  remark  statement providing explanation Non-executable Automatically colored Green in Editor Begins with an apostrophe ( ' ) On a separate line from executable code At the right end of a line of executable code ' Display the Hello World message.
Assignment Statement Assigns a value to a property or variable Operates from right to left- the value appearing on the right side of the equal sign is assigned to the property named on the left of the equal sign Enclose text strings in quotation marks (" ") messageLabel.Text=" Hello World "
Ending a Program Methods always have parentheses  (this will help you distinguish them from Properties which never have parentheses) To execute a method of an object you write: Object.Method() Current Form may be referenced as  Me Me.Close( )
Editor Window Declarations Section Class list Method list
Run, Save, Modify, Print, Test, Debug and Execute Run Project Debug Menu, Start Start  (F5)  Start Without  Debugging (CTRL+F5) Save Project - File Menu, Save All Modify Project if needed Print the Code Correct any Errors and Rerun When you start executing your program, the first step is called  compiling , which means that the VB statements are converted to Microsoft Intermediate Language (MSIL). Your goal is to have no errors during the compile process: a  clean compile .  "Help is always available from the Help Menu or by pressing F1."
Print the Code File Menu, Print Prints complete code listing Uses arrow symbol to denote line continuation
Finding and Fixing Errors Syntax Errors Breaks VB’s rules for punctuation, format or spelling Smart editor finds most syntax errors, compiler finds the rest The editor identifies a syntax error with a squiggly blue line and you can point to an error to pop up the error message. You can display the Error List window and line numbers in the source code to help locate the error lines. Run-Time Errors Statements that fail to execute such as impossible arithmetic operations Logic Errors Project runs but produces incorrect results
Naming Rules and Conventions Have a set of standards and always follow them No spaces, punctuation marks or reserved words Use  camel casing Examples messageLabel exitButton dataEntryForm paymentAmountTextBox
Recommended Naming Conventions for VB Objects introPageSoundPlayer SoundPlayer ingredientsListBox ListBox bookListComboBox ComboBox landscapePictureBox PictureBox temperatureVerticalScrollBar Vertical Scroll Bar rateHorizontalScrollBar Horizontal Scroll Bar printSummaryCheckBox CheckBox boldRadiobutton Radio button paymentAmountTextbox TextBox totalLabel Label exitButton Button dataEntryForm Form Example Object Class
Visual Studio Help Additional Info  (1 of 2) Visual Studio has an extensive Help facility, Filter MSDN help to display VB topics only Run MSDN from hard drive, CD or Web You can access MSDN on the Web at  http://msdn.microsoft.com The Help system display is greatly changed and improved in Visual Studio 2005. You view the Help topics in a separate window from the VS IDE, so you can have both windows open at the same time .
When you choose  How Do I ,  Search ,  Contents ,  Index , or  Help Favorites  from the  Help  menu, a new window opens on top of the IDE window. You can switch from one window to the other, or resize the windows to view both on the screen if your screen is large enough.  Visual Studio Help Additional Info  (2 of 2)

More Related Content

PDF
Visual basic 6.0
sanket1996
 
PDF
Visual Basic IDE Introduction
Ahllen Javier
 
PPT
Introduction to programming using Visual Basic 6
Jeanie Arnoco
 
PDF
Vb tutorial
Saikarthik103212
 
PPTX
Visual Basic Controls ppt
Ranjuma Shubhangi
 
PPT
Visual basic
sanjay joshi
 
PPT
Introduction to visual basic programming
Roger Argarin
 
PPT
Creating a quiz using visual basic 6
Ella Marie Wico
 
Visual basic 6.0
sanket1996
 
Visual Basic IDE Introduction
Ahllen Javier
 
Introduction to programming using Visual Basic 6
Jeanie Arnoco
 
Vb tutorial
Saikarthik103212
 
Visual Basic Controls ppt
Ranjuma Shubhangi
 
Visual basic
sanjay joshi
 
Introduction to visual basic programming
Roger Argarin
 
Creating a quiz using visual basic 6
Ella Marie Wico
 

What's hot (20)

PPT
Visual basic ppt for tutorials computer
simran153
 
PPT
Visual basic
umesh patil
 
PPTX
Visual Programming
Bagzzz
 
PPT
Vb basics
sagaroceanic11
 
PPT
visual basic v6 introduction
bloodyedge03
 
PDF
Vbasic
Gowri Shankar
 
PPT
Microsoft visual basic 6
Penang, Malaysia
 
PPT
Vb unit t 1.1
Gayathri Cit
 
PPT
Meaning Of VB
Mohit Verma
 
PPTX
Controls events
Dalwin INDIA
 
PPTX
Visusual basic
Mandavi Classes
 
PDF
Homework seriesandroidworkshop JUly 12th
Rishi Kumar
 
DOCX
Visual basic
Dharmik
 
PPTX
Chapter 03 - Program Coding and Design
patf719
 
PPTX
Class viii ch-7 visual basic 2008
jessandy
 
PDF
Android Homework for-july-19th-2015
Rishi Kumar
 
PDF
Visual basic 6 black book
Ajay Goyal
 
PDF
Creating Windows-based Applications Part-I
Umar Farooq
 
PPTX
Chapter 2 — Program and Graphical User Interface Design
francopw
 
PPS
Vb6.0 Introduction
Tennyson
 
Visual basic ppt for tutorials computer
simran153
 
Visual basic
umesh patil
 
Visual Programming
Bagzzz
 
Vb basics
sagaroceanic11
 
visual basic v6 introduction
bloodyedge03
 
Microsoft visual basic 6
Penang, Malaysia
 
Vb unit t 1.1
Gayathri Cit
 
Meaning Of VB
Mohit Verma
 
Controls events
Dalwin INDIA
 
Visusual basic
Mandavi Classes
 
Homework seriesandroidworkshop JUly 12th
Rishi Kumar
 
Visual basic
Dharmik
 
Chapter 03 - Program Coding and Design
patf719
 
Class viii ch-7 visual basic 2008
jessandy
 
Android Homework for-july-19th-2015
Rishi Kumar
 
Visual basic 6 black book
Ajay Goyal
 
Creating Windows-based Applications Part-I
Umar Farooq
 
Chapter 2 — Program and Graphical User Interface Design
francopw
 
Vb6.0 Introduction
Tennyson
 
Ad

Similar to Chapter 01 (20)

PPT
Ch01
guest7a6cbb3
 
PPT
Visual studio.net
Dr. C.V. Suresh Babu
 
PPTX
hjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptx
EliasPetros
 
PPT
06 win forms
mrjw
 
DOCX
Visual basic concepts
melody77776
 
DOCX
unit 4.docx
Sadhana Sreekanth
 
PDF
Ppt on visual basics
younganand
 
PPTX
01 Database Management (re-uploaded)
bluejayjunior
 
PPTX
Presentation on visual basic 6 (vb6)
pbarasia
 
PPTX
Vb.net ide
Faisal Aziz
 
PPTX
Programming basics
Senri DLN
 
PPTX
01. Exploring the Visual C# Toolbox (1).pptx
PoEnyaRaTna
 
PDF
Introduction To Computer Programming And Numerical Methods 1st Edition Xundon...
bhtbysl095
 
PDF
Membangun Desktop App
Fajar Baskoro
 
PPTX
Vb6.0 intro
JOSEPHINEA6
 
PPT
Vb introduction.
sagaroceanic11
 
PPTX
COM 211 PRESENTATION.pptx
AnasYunusa
 
PPSX
Introduction of VS2012 IDE and ASP.NET Controls
KhademulBasher
 
PPTX
Vb.net and .Net Framework
SHIVANGICHAURASIYA
 
PDF
ArduinoWorkshop2.pdf
PedramKashiani
 
Visual studio.net
Dr. C.V. Suresh Babu
 
hjksjdhksjhcksjhckjhskdjhcskjhckjdppt.pptx
EliasPetros
 
06 win forms
mrjw
 
Visual basic concepts
melody77776
 
unit 4.docx
Sadhana Sreekanth
 
Ppt on visual basics
younganand
 
01 Database Management (re-uploaded)
bluejayjunior
 
Presentation on visual basic 6 (vb6)
pbarasia
 
Vb.net ide
Faisal Aziz
 
Programming basics
Senri DLN
 
01. Exploring the Visual C# Toolbox (1).pptx
PoEnyaRaTna
 
Introduction To Computer Programming And Numerical Methods 1st Edition Xundon...
bhtbysl095
 
Membangun Desktop App
Fajar Baskoro
 
Vb6.0 intro
JOSEPHINEA6
 
Vb introduction.
sagaroceanic11
 
COM 211 PRESENTATION.pptx
AnasYunusa
 
Introduction of VS2012 IDE and ASP.NET Controls
KhademulBasher
 
Vb.net and .Net Framework
SHIVANGICHAURASIYA
 
ArduinoWorkshop2.pdf
PedramKashiani
 
Ad

More from Terry Yoast (20)

PPT
9781305078444 ppt ch12
Terry Yoast
 
PPT
9781305078444 ppt ch11
Terry Yoast
 
PPT
9781305078444 ppt ch10
Terry Yoast
 
PPT
9781305078444 ppt ch09
Terry Yoast
 
PPT
9781305078444 ppt ch08
Terry Yoast
 
PPT
9781305078444 ppt ch07
Terry Yoast
 
PPT
9781305078444 ppt ch06
Terry Yoast
 
PPT
9781305078444 ppt ch05
Terry Yoast
 
PPT
9781305078444 ppt ch04
Terry Yoast
 
PPT
9781305078444 ppt ch03
Terry Yoast
 
PPT
9781305078444 ppt ch02
Terry Yoast
 
PPT
9781305078444 ppt ch01
Terry Yoast
 
PPTX
9781337102087 ppt ch13
Terry Yoast
 
PPTX
9781337102087 ppt ch18
Terry Yoast
 
PPTX
9781337102087 ppt ch17
Terry Yoast
 
PPTX
9781337102087 ppt ch16
Terry Yoast
 
PPTX
9781337102087 ppt ch15
Terry Yoast
 
PPTX
9781337102087 ppt ch14
Terry Yoast
 
PPTX
9781337102087 ppt ch12
Terry Yoast
 
PPTX
9781337102087 ppt ch11
Terry Yoast
 
9781305078444 ppt ch12
Terry Yoast
 
9781305078444 ppt ch11
Terry Yoast
 
9781305078444 ppt ch10
Terry Yoast
 
9781305078444 ppt ch09
Terry Yoast
 
9781305078444 ppt ch08
Terry Yoast
 
9781305078444 ppt ch07
Terry Yoast
 
9781305078444 ppt ch06
Terry Yoast
 
9781305078444 ppt ch05
Terry Yoast
 
9781305078444 ppt ch04
Terry Yoast
 
9781305078444 ppt ch03
Terry Yoast
 
9781305078444 ppt ch02
Terry Yoast
 
9781305078444 ppt ch01
Terry Yoast
 
9781337102087 ppt ch13
Terry Yoast
 
9781337102087 ppt ch18
Terry Yoast
 
9781337102087 ppt ch17
Terry Yoast
 
9781337102087 ppt ch16
Terry Yoast
 
9781337102087 ppt ch15
Terry Yoast
 
9781337102087 ppt ch14
Terry Yoast
 
9781337102087 ppt ch12
Terry Yoast
 
9781337102087 ppt ch11
Terry Yoast
 

Recently uploaded (20)

PPTX
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
PPTX
Virus sequence retrieval from NCBI database
yamunaK13
 
PPTX
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
PPTX
Basics and rules of probability with real-life uses
ravatkaran694
 
PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
PPTX
How to Apply for a Job From Odoo 18 Website
Celine George
 
PPTX
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
DOCX
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
PPTX
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
Virus sequence retrieval from NCBI database
yamunaK13
 
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
Basics and rules of probability with real-life uses
ravatkaran694
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
How to Apply for a Job From Odoo 18 Website
Celine George
 
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 

Chapter 01

  • 1. aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf
  • 2. Introduction to Visual Basic.NET 2005 Chapter 1 McGraw-Hill © 2006 The McGraw-Hill Companies, Inc. All rights reserved.
  • 3. Chapter Objectives (1 of 2) Describe the process of visual program design and development Explain the term object-oriented programming Explain the concepts of classes , objects , properties , methods , and events List and describe the three steps for writing a Visual Basic project Describe the various files that make up a Visual Basic project
  • 4. Chapter Objectives (2 of 2) Identify the elements in the Visual Studio environment Define design time , run time , and debug time Write, run, save, print, and modify your first Visual Basic project Identify syntax errors , run-time errors , and logic errors Use Auto Correct to correct syntax errors Look up Visual Basic topic in Help
  • 5. Writing Windows Applications with VB (1 of 2) Windows Graphical User (GUI) Interface Defines how elements look and function
  • 6. Writing Windows Applications with VB (2 of 2) Elements are called controls and are added using a toolbox Windows are called forms
  • 7. Programming Languages-Procedural, Event Driven and Object Oriented Procedural —Cobol, Fortran, Basic Program specifies exact sequence of all operations Event Driven (VB 6.0 and previous) Contain some elements of Object oriented programming but not all Object Oriented Programming (OOP) (VB .NET) User controls sequence Click event Double Click event Change event
  • 8. The Object Model (1 of 2) In VB you will work with objects, which have properties, methods, and events. Each object is based on a class. Objects equate to Nouns Forms are windows Controls are components contained inside a form Properties equate to Adjectives Color or size of a Form Methods are like Verbs Typical methods include Close, Show and Clear
  • 9. Object Model (2 of 2) Events occur when the user takes action User clicks a button , User moves a form Classes are templates used to create a new object Classes contain the definition of all available properties, methods, and events Each new object created is based on a class Creating three new buttons makes each button a instance of the Button class
  • 10. Object Model Analogy Class = automobile Properties = make, model, color, year Object = each individual car Object is also an Instance of the automobile class Methods = start, stop, speedup, slowdown Events = car arrives, car crashes
  • 11. Visual Studio .NET Included in Visual Studio .NET 2005 Visual Basic (can also be purchased separately) Visual C++ C# (C sharp) J# (J sharp) .NET 2.0 Framework Visual Studio .NET Editions Standard Professional Enterprise Developer Enterprise Architect
  • 12. Writing Visual Basic Projects There is a three-step process when writing a Visual Basic application—you set up the user interface , define the properties and then create the code Planning Design the User Interface Plan the Properties Plan the Basic Code; follow the language syntax rules; use pseudocode (English expression or comment describing action) then you move on to Programming (and use the same three step process) Define the User Interface Set the properties Write the Basic code
  • 13. VB Application Files One Solution File—think of one solution file equals one project .sln Solution User Options File .suo Form Files .vb Resource File for the Form .resx Project Files .vbproj Project User Options File .vbproj.user Application configuration File .app.config Once a project is run several more files are created by the system. The only file that is opened directly is the solution file.
  • 14. Visual Studio Environment The Visual Studio environment is where you create and test your projects-in Visual Studio it is called an Integrated Development Environment (IDE) consists of various tools including: Form Designer Editor for entering code Compiler Debugger Object Browser Help facility
  • 15. Default Environment Settings Visual Studio 2005 provides a new option that allows the programmer to select the default profile for the IDE
  • 16. The IDE Initial Screen The Visual Studio IDE with the Start Page open, as it first appears in Windows XP, without an open project.
  • 17. IDE Main Window Toolbars Document Window Form Designer Solution Explorer Window Properties Window Toolbox Help
  • 18. ToolBox Y ou can scroll to view more controls To sort the tools in the toolbox: Right-click the toolbox and select Sort Items Alphabetically from the context menu (shortcut menu).
  • 19. Modes Design Time--used when designing the user interface and writing code Run Time--used when testing and running a project Break Time- -if/when receiving a run-time error or pause error “ Look at the Title Bar”
  • 20. Writing Your First Visual Basic Project Setting Up the Project 1 2 3 Hello World Project
  • 21. Planning the Project Design the user interface Set up the form Resize the form Place a label and a button control on the form using the toolbox Lock the Controls in place After the user interface is designed, the next step is to set the properties
  • 22. Setting Properties Label 1 Name messageLabel Text leave blank Button 1 Name pushButton Text Push Me Button 2 Name exitButton Text Exit Form Name helloForm Text Hello World by your name
  • 23. Setting the Form Properties The default startup object is Form1 The name of the form should always be changed to adhere to naming rules The properties window shows the files properties
  • 24. Writing the Code While the project is running the user can perform actions Each action by the user causes an event to occur Write code for the events you care about; the events you want to respond to with code Code is written as event procedures VB will ignore events for which you do not write code VB will automatically name event procedures as the object name, an underscore(_) and the name of the event
  • 25. More on Writing the Code When writing the code for your first project you will use the following: Remark Statement Assignment Statement Ending a Program Editor Window
  • 26. Remark Statement Also known as Comment, used for documentation; every procedure should begin with a remark statement providing explanation Non-executable Automatically colored Green in Editor Begins with an apostrophe ( ' ) On a separate line from executable code At the right end of a line of executable code ' Display the Hello World message.
  • 27. Assignment Statement Assigns a value to a property or variable Operates from right to left- the value appearing on the right side of the equal sign is assigned to the property named on the left of the equal sign Enclose text strings in quotation marks (" ") messageLabel.Text=" Hello World "
  • 28. Ending a Program Methods always have parentheses (this will help you distinguish them from Properties which never have parentheses) To execute a method of an object you write: Object.Method() Current Form may be referenced as Me Me.Close( )
  • 29. Editor Window Declarations Section Class list Method list
  • 30. Run, Save, Modify, Print, Test, Debug and Execute Run Project Debug Menu, Start Start (F5) Start Without Debugging (CTRL+F5) Save Project - File Menu, Save All Modify Project if needed Print the Code Correct any Errors and Rerun When you start executing your program, the first step is called compiling , which means that the VB statements are converted to Microsoft Intermediate Language (MSIL). Your goal is to have no errors during the compile process: a clean compile . "Help is always available from the Help Menu or by pressing F1."
  • 31. Print the Code File Menu, Print Prints complete code listing Uses arrow symbol to denote line continuation
  • 32. Finding and Fixing Errors Syntax Errors Breaks VB’s rules for punctuation, format or spelling Smart editor finds most syntax errors, compiler finds the rest The editor identifies a syntax error with a squiggly blue line and you can point to an error to pop up the error message. You can display the Error List window and line numbers in the source code to help locate the error lines. Run-Time Errors Statements that fail to execute such as impossible arithmetic operations Logic Errors Project runs but produces incorrect results
  • 33. Naming Rules and Conventions Have a set of standards and always follow them No spaces, punctuation marks or reserved words Use camel casing Examples messageLabel exitButton dataEntryForm paymentAmountTextBox
  • 34. Recommended Naming Conventions for VB Objects introPageSoundPlayer SoundPlayer ingredientsListBox ListBox bookListComboBox ComboBox landscapePictureBox PictureBox temperatureVerticalScrollBar Vertical Scroll Bar rateHorizontalScrollBar Horizontal Scroll Bar printSummaryCheckBox CheckBox boldRadiobutton Radio button paymentAmountTextbox TextBox totalLabel Label exitButton Button dataEntryForm Form Example Object Class
  • 35. Visual Studio Help Additional Info (1 of 2) Visual Studio has an extensive Help facility, Filter MSDN help to display VB topics only Run MSDN from hard drive, CD or Web You can access MSDN on the Web at http://msdn.microsoft.com The Help system display is greatly changed and improved in Visual Studio 2005. You view the Help topics in a separate window from the VS IDE, so you can have both windows open at the same time .
  • 36. When you choose How Do I , Search , Contents , Index , or Help Favorites from the Help menu, a new window opens on top of the IDE window. You can switch from one window to the other, or resize the windows to view both on the screen if your screen is large enough. Visual Studio Help Additional Info (2 of 2)

Editor's Notes

  • #2: Brief description on how to navigate within this presentation (ppt) The first time a Key Term from the chapter is used in the ppt it will display in blue Gold colored text boxes display coding examples Slides will be numbered (# of #) when multiple slides on same topic (Slide title) Speaker notes are included where appropriate for slides (*)Denotes either a comment for page reference to textbook or slide reference in ppt
  • #13: Planning- Design the user interface—draw a sketch of the screens the user will see when running the project; include forms and all controls that are to be used including the names to be assigned Plan the properties—for each object write down the properties that you plan to set or change during the design of the form Plan the Basic code—plan the classes and procedures that will execute when the project runs including determining which events require action to be taken and then make a step-by-step plan for the actions Programming- Define the user interface-- create Forms and Controls Set the properties--give each object a name and define attributes such as the contents of a label, size, Write the Basic code—use Basic programming statements to carry out the actions needed by the program
  • #14: Solution file-text file that holds information about the solution and the projects it contains; primary file Solution user options file-stores information about the selected options A.Vb file—holds the definition of a form, its controls, and code procedures Resource file—a text file that defines all resources used by the form including string of text, numbers and any graphics Project file—text file that describes the project and lists the files that are included in the project Project user option file—text file holds project option settings so that the next time a project is opened all selected options are restored
  • #15: IDE tools Form designer-visually create a form Editor-entering and modifying program code Compiler-for translating the Visual Basic statements into the intermediate machine code Debugger-to help locate and correct program errors Object browser-to view the available classes, objects, properties, methods and events Help facility-to provide answers to questions
  • #18: Toolbars—are shortcuts for frequently used operations; each button represents a command Document Window—largest window in the center of the screen; items that display in the Document window include: Form Designer, the Code Editor, the Object Browser, and the pages of Help that are requested Form Designer—where a form is designed that makes up the user interface Solution Explorer Window—holds the filenames for the files included in your project and a list of the classes it references Properties Window—used to set the properties for the objects in a project Toolbox—holds tolls that are used to place controls on a form Help—is expanded for >NET and includes the Microsoft Developer Network library containing reference materials for VB and other languages; as well as books, technical articles, Microsoft Knowledge Bases, and a database of FAQ’s.
  • #20: The Title Bar indicates which mode is currently being used.
  • #21: Step 1—set up the Workspace; run Visual Studio IDE and customize the workspace if desired Step 2—start a New Project Step 3—set up the environment—customize windows and toolbars
  • #22: Design the user interface by making a sketch of the form that includes the controls Resize the form in the document window; drag the handle (key term) in the lower-right corner Place the controls by pointing to the tool in the toolbox and clicking to select; drag the pointer over the form and the pointer becomes a crosshair; point to a spot to place the corner of the control and drag to create the control; a selected control that is selected will have 8 small square handles around it (Button 2) Once the controls have been selected and placed on the form right-click on one of the controls and select Lock Controls from the context menu
  • #23: Click on the control and then click in the properties window to select and change desired properties of the control and/or form
  • #25: You write code in VB in procedures; currently each procedure will be a sub procedure (Key Term) and being with the words Private Sub and end with End Sub
  • #26: Details for the Remark statement, assignment statement, ending a program and the editor window are shown on the following 4 slides
  • #30: When double-clicking on a button the Visual Studio editor opens with the first and last one of your sub procedure already in place and the insertion point indented inside the sub procedure Declaration section – section at the top of the file
  • #31: Run the project to determine if there are any errors (debugging) that need to be fixed. Save All saves the current form, project, and solution files to the path that was selected when you started the project. You cannot change the path after beginning a project. If wanting to move or rename the project it must be closed. Modify project is you want to change the controls or control properties such as font size, size of a label, etc.
  • #34: Using good consistent names for objects can make a project easier to read and understand, as well as easier to debug. When you select a name for an object, Visual Basic requires the name to begin with a letter or an underscore; names can contain letters, digits, and underscores but no spaces, punctuation marks or reserved words such as Exit or It. Camel casing is beginning the name with a lowercase character and capitalize each additional word in the name.
  • #36: MSDN-Microsoft Developer Network library A good way to start using Help is to view the topics that demonstrate how to look up topics in Help.
  • #37: A quick way to view Help on any topic is to use context-sensitive Help (Key term)