4. Functions and Control Statements

Slides:



Advertisements
Similar presentations
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.
Advertisements

“Going loopy with Visual Basic!”
Looping Structures: Do Loops
Do-while Loops Programming. COMP102 Prog Fundamentals I: do-while Loops /Slide 2 The do-while Statement l Syntax do action while (condition) l How it.
CSI 1306 PROGRAMMING IN VISUAL BASIC PART 2. Part 2  1. Strings  2. Translating Conditional Branch Instructions  3. Translation Set 2  4. Debugging.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Proyek Queri-queri Lanjut dan Sub-subqueri. Variables dan Data.
1 PHP Statement Constructs Server Scripting. 5-2 Basic Statement All Statements end in a semicolon. Statements are delimited from the HTML code by enclosing.
IS437: Fall 2004 Instructor: Dr. Boris Jukic Program Flow Control: Decisions and Conditions (Branching) Controlled Repetition (Looping)
Do/Loops A loop repeats a series of instructions. An iteration is a single execution of the statement(s) in the loop. Used when the exact number of iterations.
A loop is a repetition control structure. it causes a single statement or block to be executed repeatedly What is a loop?
Built-In Functions.
The Programming Discipline Professor Stephen K. Kwan 2010 Things you need to know (learn) for developing large computer programs.
Databases Lab 5 Further Select Statements. Functions in SQL There are many types of functions provided. The ones that are used most are: –Date and Time.
1 Pertemuan 06 Repetition Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
Manipulation Masterclass By the VB Gods. In this masterclass, we will learn how to use some of the string manipulation function such as Len, Right, Left,
ENGR 112 Decision Structures.
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
1 INF110 Visual Basic Programming AUBG Spring semester 2011 Reference books: Schneider D., An Introduction to Programming Using Visual Basic, Prentice.
Compunet Corporation1 Programming with Visual Basic.NET While, Do and For – Next Loops Week 5 Tariq Ibn Aziz.
Controlling Execution Programming Right from the Start with Visual Basic.NET 1/e 8.
Statements That Repeat. For...Next Loop Structure For counter = start To end Step increment statements Next counter Where Counter is tested to see if.
CSC 162 Visual Basic I Programming. Repetition Structures Pretest Loop –Exit condition is tested before the body of code is executed Posttest Loop –Exit.
Chapter 6: The Repetition Structure
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.
ㅎㅎ logical operator if if else switch while do while for Third step for Learning C++ Programming Repetition Control Structures.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #5: Programming Structures IE 212: Computational Methods for Industrial Engineering.
Lab 4 Range Review, Control Logic and Loops ► Range Review ► Control Logic and Loops ► Exercise.
‘Tirgul’ # 2 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #2.
Introduction to Problem Solving and Control Statements.
ITERATIVE STATEMENTS. Definition Iterative statements (loops) allow a set of instruction to be executed or performed several until condition are met.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Visual Basic Programming I 56:150 Information System Design.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Advanced Repetition Structure and String Functions (Unit 10) Visual Basic for Applications.
Introduction to Programming Lecture 2 Msury Mahunnah, Department of Informatics, Tallinn University of Technology.
For…Next Loops, Checked List Boxes, and Combo Boxes Chapter 5.
CECS 5020 Computers in Education Visual Basic Variables and Constants.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 13 How Long Can This Go On?
1 Microsoft® Visual Basic®.NET Language # 2. 2 Flow-Control Statements If … End If Select Case … End Select For… Next Do … Loop Exit.
Controlling Program Flow with Looping Structures
Lab 6 (1) Range Review, Control Logic and Loops ► Control Logic and Loops ► Exercise.
Fourth Quarter.  Involves loops or cycles ◦ Loops: means that a process may be repeated as long as certain condition remains true or remains false. ◦
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2B) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
CSET 3250 Client-Side Scripting VBScript : Operators, Control Structures, Procedures and Functions.
Dani Vainstein1 VBScript Session 5. Dani Vainstein2 What we learn last session? Branching Branching using If … Then … Else statement. Branching using.
CSC 162 Visual Basic I Programming. String Functions LTrim( string ) –Removes leading spaces from the left side of string RTrim( string ) –Removes trailing.
 What Does This Program Do? ACSL.  Frequently one must use or modify sections of another programmer’s code.  It is essential to be able to read and.
Control Structure  What is control Structure?  Types of Controls  Use the control structure in VBScript.  Example Summery.
Loops causes program to execute the certain block of code repeatedly until some conditions are satisfied. Suppose you want to execute some code/s 10 times.
Introduction to Programming Lecture 2
UNIT 5 Lesson 15 Looping.
Chapter 5- Control Structures: Part 2
Visual Basic 6 (VB6) Data Types, And Operators
Problem Solving and Control Statements: Part 2
Lists, Loops, Validation, and More
Control Structures: Part 2
Which of the following statements is true for this triangle?
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2B) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
Development of Internet Application 1501CT - Sara Almudauh
Control Structures: Part 1
حلقات التكرار.
The University of Texas – Pan American
Chapter (3) - Looping Questions.
Problem Solving and Control Statements
VBScript Session 10.
Case & Repetitive Statements
ASP control structure BRANCHING STATEMENTS
CSCI 1100/1202 February 6, 2002.
Presentation transcript:

4. Functions and Control Statements

Working with function String function Mathematical function Date function I/O function

String function String( ) Instr( ) InstrRev( ) Left( ) Right( ) Mid( ) Len( ) Replace( ) LTrim( ) RTrim( ) Trim( ) Str( ) Format( )

Mathematical function Abs( ) Atn( ) Sin( ) Cos( ) Tan( ) Hex( ) Oct( ) Sqr( ) Val( )

Date and Time function Now( ) Date/Date$( ) Time/Time$( ) Datepart( ) DateAdd( ) DateDiff( ) DateValue() TimeValue( ) Dateserial() Month( ) Day( ) year( ) Hour( ) Minute( )

Control statements If statements Select case statements Do statements For loop Exit

If statements The if …then structure tests the condition specified and if it’s true executes the statements that follows . Syntax:- If condition then statement

If……..Then……..Else Statement : A variation of the If..Then statement is the If..Then..Else statements, which executes one block of statements if the condition is true and other condition is false. Syntax : If condition Then statementblock-1 Else statementblock-2 End If

Select case statement The select case structure compares one expression with different values. Syntax:- Select case expression Case value 1 Statementblock-1 Csae value 2 Statementblock -2 . Case else Statementblock End select

Looping Statements Loop statements allow you to one or more lines of code repetitively. Visual Basic supports the following loop statements : 1)Do…loop 2) For…Next 3) Exit

1) Do…Loop The do… loop executes a block of statements for as long as a condition is true. There are two variations of the Do…Loop statement. A Loop can be executed either while the condition is true or Untill the condition becomes true.

To execute a block of statements while condition is true Syntax : Do while condition statement-block Loop To execute a block of statements Until the condition becomes is true Do Until condition

2) For……Next Loop The for…next loop is require to know how meny times the statements in the loopwill be executed. Syntax:- For counter = start to end [step increment] Statements Next [counter]

exit The wxit statement allows you to exit prematurely from a block of statements in a control structure, from a loop, or even from a procedure. Syntax:- exit

For ex :- For i = 0 To Ubound (nArray()) If nArray(i) < 0 Then Exit For nArray(i) = Sqr (nArray(i)) Next