Visual Basic CODE. Basics of Code Declaration Declaration Set aside a named place to put things Set aside a named place to put things Assignment Assignment.

Slides:



Advertisements
Similar presentations
Chapter 6 - VB 2005 by Schneider1 Do Loop Syntax Do While condition statement(s) Loop Condition is tested, If it is True, the loop is run. If it is False,
Advertisements

Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Integrated Business Applications with Databases (D3) Jenny Pedler
Control Structures Ranga Rodrigo. Control Structures in Brief C++ or JavaEiffel if-elseif-elseif-else-end caseinspect for, while, do-whilefrom-until-loop-end.
Object Oriented Programming A programming concept which views programs as objects with properties and ways to manipulate the object and the properties.
Pascal Programming Today Chapter 4 1 »Conditional statements allow the execution of one of a number of possible operations. »Conditional statements include:
IS437: Fall 2004 Instructor: Dr. Boris Jukic Program Flow Control: Decisions and Conditions (Branching) Controlled Repetition (Looping)
July 13 th.  If/ Else if / Else  Variable Scope  Nested if/else's  Switch statements  Conditional Operator.
Visual Basic: An Object Oriented Approach 3 – Making Objects Work.
Data Types and Operations Programming Fundamentals (Writing Code)Programming Fundamentals (Writing Code)
ACSE th Conference The Iconic Programmer Stephen Chen.
Arrays, Conditionals & Loops in Java. Arrays in Java Arrays in Java, are a way to store collections of items into a single unit. The array has some number.
VBA & Excel Barry L. Nelson IEMS 465 Fall Quarter 2003.
Mr C Johnston ICT Teacher BTEC IT Unit 06 - Lesson 05 Learning To Program.
Why to Create a Procedure
Microsoft Access Using Visual Basic Routines. Visual Basic Datatypes Boolean Byte Currency Date Double Integer Long Object Single String Variant Hyperlink.
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
Lecture 8 Visual Basic (2).
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
ENGR 112 Decision Structures.
PHP Conditional Statements Conditional statements in PHP are used to perform different actions based on different conditions. Conditional Statements Very.
Introduction to VB.NET 2005 Dr. McDaniel IDS4704 Spring 2005.
Visual Basic.net Loops. Used to do multiple executions of the same block of code Do while loops Do until loops For next loops.
Control Structures By Shyam Gurram. Control Structure In this chapter we have two different types of structures. Conditional Structure Iterative Control.
CS285 Visual Basic 2 Department of Computing UniS 1 Statements in Visual Basic A statement is the fundamental syntactical element of a program smallest.
PROGRAMMING ITERATION 2. Starter  Put the following code in order (write down the line numbers).  The program should display the numbers 1-24 on screen.
Applications Development
© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 10: Chapter 6: Slide 1 Unit 10 Sub Procedures and Functions Chapter 6 Sub.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Other Variable Types Dim lab as String makes a box that can store a label tag Dim ColHead As String ColHead = “function” ColHead function Dim lab as Boolean.
Introduction to Programming Lecture Note - 2 Visual Basic Programming Fundamentals.
Chapter 6 Looping Structures. Do…LoopDo…Loop Statement Can operate statements repetitively Do intx=intx + 1 Loop While intx < 10 –The Loop While operates.
Programming with Microsoft Visual Basic th Edition
Visual Basic CDA College Limassol Campus COM123 Visual Programming 1 Semester B Lecture:Pelekanou Olga Week 5: Useful Functions and Procedures.
CECS 5020 Computers in Education Visual Basic Variables and Constants.
Controlling Program Flow with Looping Structures
Slide 1 Controls v Control naming convention –Label: lblName –Command Button: cmdName –Text Box: txtName.
Practical Programming COMP153-08S Lecture: Repetition.
BACS 287 Programming Fundamentals 5. BACS 287 Programming Fundamentals This lecture introduces the following topics: – Procedures Built-in Functions User-defined.
Understanding Visual Basic Fundamentals CHAPTER 13 Understanding Visual Basic Fundamentals.
Fourth Quarter.  Involves loops or cycles ◦ Loops: means that a process may be repeated as long as certain condition remains true or remains false. ◦
Starting Out with Visual Basic.NET 2 nd Edition Chapter 6 Sub Procedures And Functions.
National Diploma Unit 4 Introduction to Software Development Data Structures – Loops and selection.
MIC305 Week 6 Beyond controls Review of properties Differences with VB6: using classes and instances Programming constructs.
Today… Preparation for doing Assignment 1. Invoking methods overview. Conditionals and Loops. Winter 2016CMPE212 - Prof. McLeod1.
Control Structure  What is control Structure?  Types of Controls  Use the control structure in VBScript.  Example Summery.
Chapter 6 Controlling Program Flow with Looping Structures.
Selection Using IF THEN ELSE CASE Introducing Loops.
 Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do.
CE En 270 Brigham Young University Norm Jones
Sub Procedures And Functions
Visual Basic Fundamental Concepts
A variable is a name for a value stored in memory.
VBA - Excel VBA is Visual Basic for Applications
Method.
Expressions and Control Flow in JavaScript
Chapter 5 Structures.
Visual Basic..
Outline Altering flow of control Boolean expressions
Visual Basic 6 Programming.
Chapter (3) - Looping Questions.
Chapter 7: Using Functions, Subs, and Modules
CISC124 Labs start this week in JEFF 155. Fall 2018
Computer Science Core Concepts
CMPE212 – Reminders The other four assignments are now posted.
Dictionary Builder Part 4 Loading Files.
Intro to Programming Concepts
The structure of programming
For...Next Statements.
Presentation transcript:

Visual Basic CODE

Basics of Code Declaration Declaration Set aside a named place to put things Set aside a named place to put things Assignment Assignment Put things in a named place Put things in a named place Control Control Interrupt the “top-to-bottom” flow of the program Interrupt the “top-to-bottom” flow of the program Subroutines and Functions Subroutines and Functions Write code once and invoke it from many places Write code once and invoke it from many places

Declaration Declares a space (like a mailbox slot) for storage of data. Declares a space (like a mailbox slot) for storage of data. Specify the name of the variable, and the type it is. For now, consider types of Integer, Boolean, String, Single/Double. Specify the name of the variable, and the type it is. For now, consider types of Integer, Boolean, String, Single/Double. Syntax: DIM name AS type Syntax: DIM name AS type DIM lastButton AS Integer DIM myResponse AS String

Assignment Assign a value or expression to a storage place. Assign a value or expression to a storage place. The storage place can be a simple variable, or a property of a control. The storage place can be a simple variable, or a property of a control. Variable = expression Variable = expression command1.visible = False lastButton = 2 Matches = (lastButton = 1) AND (thisButton <> 0)

Control Program normally proceeds from line to line. Program normally proceeds from line to line. Control statements cause other parts of code to run. Control statements cause other parts of code to run. IF expression THEN code to run if ‘expression’ not 0 ELSE code to run if ‘expression’ is 0 END IF

Control Example: IF lastButton <> 0 THEN command1.Visible = False command1.Visible = False END IF IF lastButton THEN thisButton = lastButton ELSE command1.caption = “First Pressed” END IF

Control Other control mechanisms Other control mechanisms FOR variable = startVal TO endVal NEXT variable DO WHILE expression LOOPDO LOOP WHILE expression DO LOOP UNTIL expression

‘Sub’ routines Put several lines of code in a ‘sub’ and then you can execute all of that code with one line: Put several lines of code in a ‘sub’ and then you can execute all of that code with one line: Sub MySub() Sub MySub() Command1.Picture = LoadPicture(“”) Command2.Picture = LoadPicture(“”) Command3.Picture = LoadPicture(“”) End Sub End Sub Private Sub Command1_Click() call MySub call MySub End Sub

Functions Subroutines that return a value. Subroutines that return a value. Public Function YtoM(Y AS Single) AS Single YtoM = Y * 0.9 YtoM = Y * 0.9 End Function … Yards = 10 Yards = YtoM(Yards)