CSCI 3131.01 Chapter 2 Creating Application with Visual Basic Instructor: Bindra Shrestha University of Houston – Clear Lake.

Slides:



Advertisements
Similar presentations
Creating Applications With Visual Basic
Advertisements

Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 2- 1 STARTING OUT WITH Visual Basic 2008 FOURTH EDITION Tony Gaddis.
Introduction to Visual Basic.NET Uploaded By: M.Sheraz anjum.
Chapter 1: An Introduction to Visual Basic 2012
Chapter 2 –Visual Basic, Controls, and Events
Chapter 1: An Introduction to Visual Basic.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Chapter Creating Applications With Visual Basic 2.
Chapter Creating Applications With Visual Basic 2.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Copyright © 2012 Pearson Education, Inc. Chapter 2 Introduction to Visual C#
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
Copyright © 2014 Pearson Education, Inc. Chapter 2 Creating Applications with Visual Basic.
110-C1 Chapter 2 of the text: _ text boxes, group boxes, check boxes, radio buttons, picture boxes _ defining access keys tab sequence setting the focus.
Chapter 2 –Visual Basic, Controls, and Events
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter One An Introduction to Visual Basic 2010.
2. Introduction to the Visual Studio.NET IDE 2. Introduction to the Visual Studio.NET IDE Ch2 – Deitel’s Book.
Slide 1 Chapter 2 Visual Basic Interface. Slide 2 Chapter 2 Windows GUI  A GUI is a graphical user interface.  The interface is what appears on the.
© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 1: Chapter 2: Slide 1 Unit 1 Introduction to Programming Using VB.NET Chapter.
Visual Basic Chapter 1 Mr. Wangler.
05/09/ Introducing Visual Basic Sequence Programming.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
IE 411/511: Visual Programming for Industrial Applications
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Chapter 3 Introducing Visual Basic.NET. 3.1 Visual Basic.NET Windows Programming -Used to create Windows, Web, and Console applications -Uses predefined.
Chapter 1: An Introduction to Visual Basic 2005 Programming with Microsoft Visual Basic 2005, Third Edition.
Chapter 21 Creating Applications with Visual Basic.NET Chapter 2.
Chapter 2 More Controls Programming in C#. NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 4 I Need a Tour Guide.
Chapter 3: Using GUI Objects and the Visual Studio IDE.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 2 Creating a User Interface.
Starting Out with Visual Basic.NET 2 nd Edition Chapter 2 Creating Applications With Visual Basic.NET.
Introduction to Visual Basic.NET Chapter 2 Introduction to Controls, Events.
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Copyright © 2014 Pearson Education, Inc. Chapter 2 Creating Applications with Visual Basic.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Introduction to Visual Basic.NET Your First Visual Basic.NET Application.
Program Design and Coding
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
Chapter Two Designing Applications Programming with Microsoft Visual Basic th Edition.
Chapter Two Creating a First Project in Visual Basic.
OBJECTIVES: To open an existing Project called HelloWorld. To learn how set properties using the property window and how to set them in the code. Chapter.
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Chapter 2 Creating Applications with Visual Basic.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Chapter 3 - VB.NET by Schneider1 Chapter 3 – Fundamentals of Programming in VB.NET Part I VB.NET Controls VB.NET Events.
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to the Visual Studio.NET IDE Outline 2.1Introduction 2.2Visual Studio.NET Integrated.
Microsoft Visual Basic 2005 BASICS Lesson 3 Events and Code.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 4 Designing the Inventory Application Introducing TextBox es and Button s.
Chapter 2 More Controls Programming in C#. NET Objectives Use text boxes, group boxes, check boxes, radio buttons, and picture boxes effectively.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
Object-Oriented Application Development Using VB.NET 1 Chapter 2 The Visual Studio.NET Development Environment.
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Chapter 2 Creating Applications with Visual Basic.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
 You won’t write a single line of program code.  Instead, you’ll use visual programming techniques.  Visual Studio processes your actions (such as mouse.
Programming with Microsoft Visual Basic 2012 Chapter 1: An Introduction to Visual Basic 2012.
Chapter 1: An Introduction to Visual Basic .NET
Visual Basic.NET Windows Programming
Chapter 2: The Visual Studio .NET Development Environment
Chapter 1: An Introduction to Visual Basic 2015
Chapter 2 Visual Basic Interface
Creating Applications with Visual Basic
CIS16 Application Development Programming with Visual Basic
STARTING OUT WITH Visual Basic 2008
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Presentation transcript:

CSCI Chapter 2 Creating Application with Visual Basic Instructor: Bindra Shrestha University of Houston – Clear Lake

Acknowledgement Dr. Xinhua Chen And Starting Out with Visual Basic 2010 by Tony Gaddis and Kip Irvine

Topics Building the Directions application Responding to events Modifying properties of a control with code: Text, Autosize, BorderStyle, and TextAlign properties Clickable images Using Visual Studio Help Debugging an application

Steps to Create an Application 1.Clearly define what the application is to do. 2.Visualize the application running on the computer and design its user interface 3.Make a list of the controls needed. 4.Define the values of each control’s relevant properties. 5.Start Visual Basic and create the forms and other controls

Clearly Define the Task of the Application Purpose: Display a map to the Highlander Hotel Input: None Process: Display a form Output: Display on the form a graphic image showing a map Specifications of the Application

Visualize and Design the User Interface

Points to Watch while Designing User Interface Follow the convention of Windows Graphic User Interface (GUI) design. Most Windows application consists of (1) a main (primary) window, (2) possibly some other primary windows, and (3) one or more secondary windows, called dialog boxes. The Windows Notepad application uses the primary window for editing the document; it uses a dialog box for selecting the font related properties. Primary windows can be resized, minimized, maximized and closed by the user.

Using Graphics, Fonts and Color in User Interface Using graphics, fonts and colors appropriately helps the information flow more efficiently from the user interface to the users. Inappropriate use of graphics, fonts and colors distracts the users and may also offend some of the users.

List the Controls Needed Control TypeControl NameDescription FormForm1A small form that will serve as (Default Name)the window onto which the other controls will be placed LabelLabel1Displays the message (Default Name)"Directions to the Highlander Hotel" PictureBoxPictureBox1Displays the graphic image (Default Name)showing the map to the hotel

Define Control Relevant Property Values Form –Name: Form1 –Text: "Directions" Label –Name: Label1 –Text: "Directions to the Highlander Hotel" –TextAlign: MiddleCenter –Font: Microsoft sans serif, bold, 18 point PictureBox –Name: PictureBox1 –Picture: HotelMap.jpg –SizeMode: StretchImage

Use VB to Create the Application Establish the Form and set its Text property Add a Label control –Position and resize it on the form –Set Text, TextAlign, and Font properties Add a PictureBox control –Position and resize it on the form –Set Image property to display HotelMap.jpg Run the application Close and save the application

Responding to Events An Application Responds to Events, Such As Mouse Clicks Keyboard Input The code that handles the events are called Event Handlers or Event Procedures Write the Event Procedures for the Directions Application

Augment the Hotel Application Now the hotel owner wants to add an option to view written directions:

Controls to be Added Control TypeControl NameDescription LabellblDirectionsDisplays written directions to the hotel ButtonbtnDisplayDirectionsWhen clicked, causes lblDisplayDirections text to appear on the form ButtonbtnExitStops the application when clicked

Control Properties Label: –Name: lblDirections –Text: “Traveling on I-89, take…” –Visible: False Button: –Name: btnDisplayDirections –Text: “Display Directions” Button: –Name: btnExit –Text: "Exit"

Method btnDisplayDirections_Click Private Sub btnDisplayDirections_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnDisplayDirections.Click ' Make the directions visible lblDirections.Visible = True End Sub Line Continuation Mark Name of the event the procedure responds to Name of the control that owns the event procedure Marks the beginning of this event procedure Makes the control lblDirections visible: Assigns the value True to the Visible Property of the lblDirections control. Event handled by this procedure

Syntax for Referring to the Value of a Control's Property Specify the control name (lblDirections) Then a dot Then the PropertyName (Visible) For example: –lblDirections.Visible –refers to the Visible property of the lblDirections control –The visible property values may only be true or false

Syntax for an Assignment Statement Specify the item to receive the value Then the equal symbol Then the value to be assigned For example: –lblDirections.Visible = True –Assigns the value True to the Visible property of the lblDirections control –Causes the text of the lblDirections control to become visible to the user

Method btnExit_Click Private Sub btnExit_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnExit.Click ' End the application by closing the window Me.Close() End Sub Line Continuation Mark Name of the event the procedure responds to Name of the control that owns the event procedure Marks the beginning of this event procedure Closes the current form, referred to as Me, and ends the program Event handled by this procedure

Modifying the Text Property in Code Private Sub btnFeet_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnFeet.Click ' Display the conversion to feet. lblMessage.Text = "1 Kilometer = 3,281 feet" End Sub Assigns the string to the right of the equal sign to the text property of lblMessage This replaces the previous text property of lblMessage with the new value shown

AutoSize Property for Labels AutoSize is a Boolean (either True or False) Property of labels False (the default) means the box size will not change, regardless of the amount of text assigned to it True means the box will automatically resize itself to fit the amount of text assigned to it

BorderStyle Property for Labels BorderStyle determines the look of the box –None (the default) means no border –FixedSingle results in a border one pixel wide –Fixed3D gives the border a recessed 3-dimensional look

TextAlign Property for Labels The value of TextAlign establishes the alignment (or justification) or the text: TopLeft TopCenter TopRight The assignment statement below forces the text of lblTitle to appear in the middle center of the label lblTitle.TextAlign = ContentAlignment.MiddleCenter MiddleLeft MiddleCenter MiddleRight BottomLeft BottomCenter BottomRight

Clickable Images Controls other than Buttons can have Click event procedures. PictureBox controls can respond to mouse clicks For example, if a national flag image is clicked, you may use a label to display the name of the country: Private Sub picUSA_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles picUSA.Click ' Display the country name lblMessage.Text = "United States of America" End Sub

Microsoft Document Explorer The Visual Studio Help, also called Microsoft Document Explorer, contains these options: –How Do I – a task-based topics list by category –Search – find help topics using words/phrases –Contents – displays a table of contents for help –Index – Search using predefined keywords –Favorites help – lets you bookmark help topics –Dynamic help – help for current task performed

Context-Sensitive Help (F1 Key) Displays information about whatever feature the user is currently focused on For example: –Click on a Button control –Press F1 –Help explains all about the Button control –Click on a Label control –Press F1 –Help explains all about the Label control

Debugging: Compilation Errors These are errors in the syntax (form) of your program Visual Basic will inform you of these errors as soon as the code is entered The area of the error will be underlined with a jagged blue line A description of the error will be given in the Error List window Display this window by selecting Error List from the View menu option

Debugging: Runtime Errors Some errors occur as your program runs These are different from syntax errors which occur as the code is entered by the programmer Runtime errors occur when Visual Basic attempts to perform an operation that cannot be executed