Introduction to Visual Basic (VB)

Slides:



Advertisements
Similar presentations
VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming.
Advertisements

Introduction to Visual Basic.NET Uploaded By: M.Sheraz anjum.
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
Visual Basic Project Files:.VBP file: Project File: a small text file that contains the names of other files in the project, as well as some information.
Introduction to Visual Basic Programming. Lecture Outline History What is Visual Basic First Look at the VB 6.0 Environment Some VB Terminology Our first.
Using Visual Basic 6.0 to Create Web-Based Database Applications
Visual Basic Project Files:.VBP file: Project File: a small text file that contains the names of other files in the project, as well as some information.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Using the Visual Basic Editor Visual Basic for Applications 1.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Introduction to Visual Basic. What is Visual Basic? An environment for developing Windows applications Components –A GUI (Graphical User Interface - gooey)
Copyright © 2001 by Wiley. All rights reserved. Chapter 1: Introduction to Programming and Visual Basic Computer Operations What is Programming? OOED Programming.
Introduction to Programming and Visual Basic
Visual Basic Chapter 1 Mr. Wangler.
Hands-on Introduction to Visual Basic.NET Programming Right from the Start with Visual Basic.NET 1/e 6.
Learning Objectives Data and Information Six Basic Operations Computer Operations Programs and Programming What is Programming? Types of Languages Levels.
Microsoft Visual Basic 2005: Reloaded Second Edition
CIS 338: Creating ActiveX Controls Dr. Ralph D. Westfall March, 2003.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Chapter 1 P. 1 Writing Windows applications with Visual Basic Figure 1.1 The first program works as follows: (These operations can be performed in any.
Using Visual Basic 6.0 to Create Web-Based Database Applications
An Introduction to Visual Basic
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
Introduction to Visual Basic.NET Chapter 2 Introduction to Controls, Events.
Irwin/McGraw-Hill © The McGraw-Hill Companies, Inc., Visual Basic Projects Project Structure and VB’s Programming Tools chapter TWO.
Copyright © 2001 by Wiley. All rights reserved. Chapter 2: Using Visual Basic to Create a First Project Getting Started with VB Development Environment.
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Starting Out with Visual Basic.NET 2 nd Edition Chapter 1 Introduction to Programming and Visual Basic.NET.
Tutorial 11 Five windows included in the Visual Basic Startup Screen Main Form Toolbox Project Explorer (Project) Properties.
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
CHAPTER TWO INTRODUCTION TO VISUAL BASIC © Prepared By: Razif Razali 1.
Chapter Two Creating a First Project in Visual Basic.
Vocabulary in VB So Far. Assignment: Used to change the value of an object at run time Used to change the value of an object at run time.
Copyright © 2011 Pearson Addison-Wesley What is a Program Made Of? Keywords (Reserved Words) – Words with special meaning that make up a high-level programming.
Chapter One An Introduction to Programming and Visual Basic.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Hands-on Introduction to Visual Basic.NET Programming Right from the Start with Visual Basic.NET 1/e 6.
 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 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
McGraw-Hill © 2009 The McGraw-Hill Companies, Inc. All rights reserved. Introduction to Visual Basic 2008 Chapter 1.
Object-Oriented Application Development Using VB.NET 1 Chapter 2 The Visual Studio.NET Development Environment.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 14 Event-Driven Programming with Graphical User Interfaces.
Visual Basic.NET Programming for the Rest of Us Keith Mulbery Utah Valley State College.
Visual Basic.Net. Software to Install Visual Studio 2005 Professional Edition (Requires Windows XP Pro) MSDN Library for Visual Studio 2005 Available.
 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.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Visual Basic.NET Windows Programming
Chapter 2: The Visual Studio .NET Development Environment
Introduction to Programming and Visual Basic .NET
An Introduction to Computers and Visual Basic
An Introduction to Programming and VB.NET
1. Introduction to Visual Basic
An Introduction to Computers and Visual Basic
Chapter 2 Visual Basic Interface
VISUAL BASIC.
Hands-on Introduction to Visual Basic .NET
CIS16 Application Development Programming with Visual Basic
Building an Application in the Visual Basic .NET Environment
CS285 Introduction - Visual Basic
Chapter One: An Introduction to Programming and Visual Basic
An Introduction to Computers and Visual Basic
Presentation transcript:

Introduction to Visual Basic (VB)

Topics 1. What is VB? 2. What is Event-Driven? 3. What is Object-Orientation? 4. Objects used in VB 5. VB objects naming practice 6. Files in VB 7. OOED Programming process 8. VB statements 9. VB Help

What is VB? A windows-based system using objects responding to events An objected-oriented event-driven programming language

Event-Driven Procedural languages – run from start to finish with no human intervention Basic, COBOL, FORTRAN, C Event driven languages - waits for an event to occur before taking any action Example of event The press of a key on the keyboard Movement of the mouse The click of a mouse button Programming in Windows is usually termed event-driven programming

Objects Reusable software components that model items in the real world e.g. GPA calculator, Tax calculator They are self-contained modules that combine data and program code which pass strictly defined messages to one another

Encapsulation The capability of an object to hide its internal workings from other objects. In VB, programmers does not need to know what is going on inside the object, but only need to know how to work with the object’s properties and methods How many drivers are mechanics?

Object-Oriented Event-Driven Programming (OOED) OOED uses objects in the program and runs only after the Events occur OOED is easier to work with Users can combine multiple objects to create new systems or extend existing ones

Starting VB from your computer … Toolbox [p. 27] Project Window [p. 28] useful icons Properties windows [p. 30] How to Add Controls [p. 36] How to Add Code [p. 39] The toolbar icons [p. 43]

1st Project (ShowName) A Form Three Command Buttons One Text Box Click Me Exit One Text Box One Label

Forms and Controls as Objects Forms and Controls are two kinds of objects you may use in VB A form is a virtual blank space to design the user interface for a VB application The tools that you use to construct the user interface are controls E.g. command button and textbox etc.

VB objects naming practice: Start the name with a standard object abbreviation cmd = command button, txt = text box, frm = form. Finish the name with a descriptive word of the objects purpose Spaces and special characters are not allowed in an objects name. (E.g. cmdCancel) Examples might be: frmMain.BackColor = vbRed txtState.Text = ""

Features of Objects The programmer can manipulate the object through the use of three key object features: properties methods events

Object Properties A property is a named attribute of an object. Using an analogy to English grammar, if an object is thought of as a noun, then a property may be thought of as an adjective. Used to change the appearance of objects. An example of the relationship between objects and properties using an everyday object: shirt.color = "Green“ shirt.launder = "Clean“ We use dot (“.”) notation

Setting Values of Properties During design time, properties may be set in the Properties Window. You are in “Design Time” when you are designing the project and adding code Some properties may be set or modified during run time. You are in “Run Time” when you click the VCR Run icon

Object Methods A set of predefined activities that an object can carry out. The syntax for using an objects method is: object.method A method is a verb that can be carried out by the object. For the various VB objects, there are usually several methods already available. Or advanced programmers can create their own methods.

Methods Example Real life example A Visual Basic example dog.eat dog.bark dog.run A Visual Basic example E.g. frmMain.hide

Object Event VB example An action taken by the object when notified by a message Or, user actions taken on the object that provokes a response from the object. Examples Soccer ball: kicking, throwing, holding etc. Cat: feeding, hitting, calling etc. mouse click, form load, or key press. VB example Private Sub cmdsubmit_Click() … End Sub

Files in Visual Basic All projects in VB have a .vbp (project) file and at least one .frm (form file) file. Always save .frm files first and then save project files. Use File|Save or File|Save as… commands for this purpose or click Disk icon on toolbar. Projects with graphics also have .frx (binary form) files. They are saved automatically. Module files have a .bas extension and are pure code files.

Save files Save early. All three types can and should have same names. Important! Save early. All three types can and should have same names. Eliminate prefix (eg.frm)

Add graphic Retrieve your 1st project from your disk Use image control Select a graphic Change the size of graphic Stretch property of image control Save the project

Save it Use your last name Eg. chen.frm, chen.vbp, chen.frx Create a folder in your disk composed of your name Copy files to your folder Drag the folder to: W:\apps\classes\mist4600\homework\ Dchen\testfile folder

OOED Programming Process A six step process for writing an OOED computer program: 1. Define problem. 2. Create interface 3. Develop logic for action objects 4. Write and test code for action objects 5. Test overall project 6. Document project in writing

More Practice (step 1 to 3 only) Circle problem revisit I: radius P: calculate circumference, calculate area O: radius, circumference, area Payroll problem revisit I: employee name, pay rate, and hours worked P: calculate gross pay O: gross pay

Comments To explain the purpose of a program, or a statement, a comment statement is added For yourself and others Any statement beginning with an apostrophe or REM is a comment Comments can be added to end of statements using apostrophe

VB Statements A statement is a reserved word Statements are instructions that are built into the Visual Basic language Some examples are: End Option Explicit Private Sub Dim

Visual Basic Help There are three types of Help: Help menu option context-sensitive help and Auto Help In VB 6, Help uses the familiar Internet Explorer browser interface for the first two types of help. You can seek help by selecting Contents, Index, or Search from the Help menu item

Context-Sensitive and Auto Help With context-sensitive help, pressing the F1 key provides help on whatever item the cursor is located. With Auto Help, VB tries to help you with a code statement by providing: A list of items to complete the statement Info on the statement you have started Tips on the type of data you are working with