CS285 Introduction - Visual Basic

Slides:



Advertisements
Similar presentations
Integrated Business Applications with Databases (D3) Jenny Pedler
Advertisements

CSM18 Visual Basic Section1 Department of Computing UniS 1 CSM18 Interactive Computing Introduce Visual Basic language - provides excellent facilities.
Introduction to Visual Basic.NET Uploaded By: M.Sheraz anjum.
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
The Initial Visual Basic Screen
CVEV 118/698 Visual Basic Lecture 1 Prof. Mounir Mabsout Expert 1: Elsa Sulukdjian Expert 2: Walid El Asmar.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
Using the Visual Basic Editor Visual Basic for Applications 1.
Visual Basic: An Object Oriented Approach 4: Simple Programming in VB.
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)
VBA & Excel Barry L. Nelson IEMS 465 Fall Quarter 2003.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
Introduction to Visual Basic (VB)
Automating Tasks with Visual Basic. Introduction  When can’t find a readymade macro action that does the job you want, you can use Visual Basic code.
Tutorial 11 Using and Writing Visual Basic for Applications Code
1 Visual Basic for Applications (VBA) for Excel Prof. Yitzchak Rosenthal.
® Microsoft Access 2010 Tutorial 11 Using and Writing Visual Basic for Applications Code.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
1 1 Lab1 Ismail M. Romi – IT Dept, PPU, Visual Basic 2005 Programming Tour.
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.
Outline Software and Programming Program Structure Tools for Designing Software Programming Languages Introduction to Visual Basic (VBA)
CHAPTER TWO INTRODUCTION TO VISUAL BASIC © Prepared By: Razif Razali 1.
Chapter Two Creating a First Project in Visual Basic.
Chapter 4 - Visual Basic Schneider1 Chapter 4 General Procedures.
MS Visual Basic 6 Walter Milner. VB 6 0 Introduction –background to VB, A hello World program 1 Core language 1 –Projects, data types, variables, forms,
Practical Programming COMP153-08S Week 5 Lecture 1: Screen Design Subroutines and Functions.
ME 142 Engineering Computation I Using Subroutines Effectively.
Chapter-1 Introduction to Visual Basic GUI- A GUI is a graphical (rather than purely textual) user interface to a computer. The term came into existence.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
ME 142 Engineering Computation I Using Subroutines Effectively.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
Visual Basic Review LBS 126. VB programming Project Form 1Form 2Form 3 Text boxButton Picture box Objects Text box Button Objects.
National Diploma Unit 4 Introduction to Software Development Procedures and Functions.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Visual Basic Fundamental Concepts
Programming Right from the Start with Visual Basic .NET 1/e
VISUAL BASIC 6.0 Designed by Mrinal Kanti Nath.
A variable is a name for a value stored in memory.
Chapter 2: The Visual Studio .NET Development Environment
Programming in visual basic .net Visual Basic Building Blocks
VBA - Excel VBA is Visual Basic for Applications
Chapter 1: An Introduction to Visual Basic 2015
Visual Basic Code & No.: CS 218
Functions and Procedures
An Introduction to Programming
1. Introduction to Visual Basic
2. Understanding VB Variables
Microsoft Access Illustrated
Objectives Learn about Function procedures (functions), Sub procedures (subroutines), and modules Review and modify an existing subroutine in an event.
VISUAL BASIC.
Visual Basic..
Hands-on Introduction to Visual Basic .NET
CIS16 Application Development Programming with Visual Basic
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
Introduction to Problem Solving and Control Statements
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
Introduction to Programming
Chapter 8 - Functions and Functionality
An Introduction to Programming
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Introduction to Computer Programming IT-104
Tutorial 11 Using and Writing Visual Basic for Applications Code
Presentation transcript:

CS285 Introduction - Visual Basic Programming paradigms: Procedural Programming Declarative Programming Spreadsheet programming Real-Time programming Event Driven Programming Recommended Texts: Visual Basic - an Object Oriented Approach by A McMonnies An Introduction to Visual Basic by D Schneider Department of Computing UniS CS285 VB-1 Department of Computing UniS

Procedural Programming CS316 7/12/99 Procedural Programming List of instructions - code Execution proceeds from one instruction to next Need for sequence control - logical condition Hence branching and repeating structures The concept of Algorithm: a finite number of steps to carryout a specific task eg receipt to bake a cake Department of Computing UniS CS285 VB-1 Department of Computing UniS

Declarative Programming CS316 7/12/99 Declarative Programming Declare statements or facts that are true Declare relations between facts Interrogate the system - is this true? Response Yes or No Good for solving logical problems - don’t have to tell the computer how to do it as you do in the case of procedural programming via the algorithm Department of Computing UniS CS285 VB-1 Department of Computing UniS

Spreadsheet Computations CS316 7/12/99 Spreadsheet Computations Declare relation between one cell and another = B3*1.1 10 11 Cell B3 Formulae 10 Value Limited capability eg can’t put data into a cell based upon the result of a calculation Department of Computing UniS CS285 VB-1 Department of Computing UniS

Department of Computing UniS CS316 7/12/99 Real Time Programming Procedural language that can respond to time At 1200 do . . . . Used for control of real systems such as power stations System can collect data directly from the real world eg read the temperature of furnace via an analog to digital converter Department of Computing UniS CS285 VB-1 Department of Computing UniS

Event Driven Programming CS316 7/12/99 Event Driven Programming Procedural language to support a user interface Processes are initiated by an event on screen eg user clicks a button Large code split into smaller blocks - subroutines that are associated with events A major feature of Visual Basic All the features of the windows environment are readily available in Visual Basic Department of Computing UniS CS285 VB-1 Department of Computing UniS

Department of Computing UniS CS316 7/12/99 Visual Basic Integrated Development Environment - IDE provides for all the facilities to build, test and execute a program Exploration of the IDE is the first lab assignment Department of Computing UniS CS285 VB-1 Department of Computing UniS

IDE Visual Basic - ToolBox CS316 7/12/99 IDE Visual Basic - ToolBox Department of Computing UniS CS285 VB-1 Department of Computing UniS

IDE VB - PropertiesWindow CS316 7/12/99 IDE VB - PropertiesWindow Department of Computing UniS CS285 VB-1 Department of Computing UniS

Department of Computing UniS CS316 7/12/99 IDE VB Project - Window Department of Computing UniS CS285 VB-1 Department of Computing UniS

Department of Computing UniS CS316 7/12/99 IDE VB Form - TextBox Department of Computing UniS CS285 VB-1 Department of Computing UniS

Department of Computing UniS CS316 7/12/99 IDE VB - Text1 Code Department of Computing UniS CS285 VB-1 Department of Computing UniS

Department of Computing UniS CS316 7/12/99 IDE VB - Execution Run Start Break End Also icons on the ToolBar Department of Computing UniS CS285 VB-1 Department of Computing UniS

IDE VB - Event Text1_Click CS316 7/12/99 IDE VB - Event Text1_Click Department of Computing UniS CS285 VB-1 Department of Computing UniS

Department of Computing UniS CS316 7/12/99 IDE VB - TextBox Events Department of Computing UniS CS285 VB-1 Department of Computing UniS

IDE VB - Immediate Window CS316 7/12/99 IDE VB - Immediate Window Used to display values of variables when program interrupted Department of Computing UniS CS285 VB-1 Department of Computing UniS

Department of Computing UniS CS316 7/12/99 Visual Basic IDE User Form Menu Bar Tool Bar Tool Box Project window - lists the files that constitute the program Properties window Immediate window Locals window Watch window Form layout window Department of Computing UniS CS285 VB-1 Department of Computing UniS

Visual Basic Structure Forms: containing interface objects Form Objects: contain VB Code in event driven subroutines (Sub) General: area for each Form to hold declarations for the Form and definitions of Procedures: Sub Procedures Function Procedures Modules: contains Global Visual Basic Code in the form of Procedures Class Modules (Objects): provide a Object Oriented programming environment Department of Computing UniS CS285 VB-1 Department of Computing UniS

Visual Basic Program Structure Department of Computing UniS CS285 VB-1

VB Programming Constructs Data stored in variables that must be declared Assignment statement = Operators: simple arithmetic (+, -, *, /...) string (text) manipulation date manipulation Event Handlers Department of Computing UniS CS285 VB-1

Visual Basic Event Handlers A special form of Sub that Visual Basic associates with an event Mouse operation Key-press Signal from another application An event handler is called automatically when the event happens Program can respond to external stimuli Private Sub Botton1_Click() MsgBox “Hello World” End Sub Department of Computing UniS CS285 VB-1

Visual Basic Declarations Variables need to be declared with the name and the type of data Integer types (Byte, Integer, Long) for whole numbers Floating point types (Single, Double) for numbers with fractional parts Dates and times (one type, Date, for both) Fixed point types (Decimal, Currency) for high precision (many digits) String type for text Department of Computing UniS CS285 VB-1

Visual Basic Variable Scope Where a variable can be accessed depends on how it is declared Local scope (Dim) – only within Procedure (Sub or Function) in which it is declared Module Scope (Private) – available in every Procedure within a module Global Scope (Public) – available throughout application Controlling scope makes it possible to work within contexts, so that variable names can be reused with no conflicts Department of Computing UniS CS285 VB-1

Visual Basic Declarations Dim index As integer Can be placed anywhere Private name As String Declarations in General section Only accessible from same module Public today As Date Declarations in General section Accessible anywhere Department of Computing UniS CS285 VB-1

Visual Basic Module Structure Every module has General Declarations section Subroutines (Subs) and Functions Form modules also have User interface elements (which appear on-screen) Event handlers Class modules also have Event receptors (objects that can respond to events) Department of Computing UniS CS285 VB-1

VB Local & Static Variables Local variables (within Sub or Function) Declared with Dim are reset to zero every time Procedure is called Declared with Static, retain their value Sub Forgettable( ) Dim Number As Integer Number = Number + 1 End Sub Always 1 at End Sub Sub Persistent() Dim CallCount As Integer CallCount = CallCount + 1 End Sub Counts up Department of Computing UniS CS285 VB-1

Visual Basic Variant Type A Variant is an all purpose variable Type is always Variant Sub-Type matches whatever value is assigned Sub-Type changes to suit Private Sub SquareRoot_Click() Dim V As Variant V = 2 Assign an integer V = Sqr(V) Assign a double V = “Root 2 = “ & V Assign a string End Sub Department of Computing UniS CS285 VB-1

Department of Computing UniS VB User Defined Types A UDT is composed of simple types (Integers, strings etc.) Each instance contains one of each component variable Must be placed in Standard Modules Definition is Global (available throughout program) Useful for grouping related information Department of Computing UniS CS285 VB-1

Visual Basic - An example UDF Type PhoneEntry Name As String Telephone As String End Type Dim PE As PhoneEntry PE.Name = “Fred Bloggs” PE.Telephone = “2468” Print PE.Name, PE.Telephone Department of Computing UniS CS285 VB-1

Visual Basic Subs & Functions All executable statements must be part of a Sub or Function in VB Sub – an operation, delineated by Sub and End Sub, containing a sequence of statements a Sub ‘call’ is a statement that invokes the Sub (executes the operation) Function – similar to a Sub, but returning a value as a result a function call is an expression – can be used as a value in another expression or statement Both Subs and Functions can have parameters or arguments – variables used to get information in and/or out of the Sub/Function Department of Computing UniS CS285 VB-1

Department of Computing UniS Visual Basic Subs Sub Greeting (Name As String) MsgBox “Hello “ & Name End Sub Greeting (“John”) Greeting “John” Call Greeting (“John”) Department of Computing UniS CS285 VB-1

Visual Basic Functions Function Add (X As Integer, Y As Integer) Add = x + Y End Add MsgBox ( Add(2,3)) Department of Computing UniS CS285 VB-1

CS316 7/12/99 End of Section 1 Department of Computing UniS