SlideShare une entreprise Scribd logo
1  sur  13
Control Structures

In Visual Basic

Submitted By:
Sakar Chiolunkar
Shashank Baghel
Tushar jain

12C3045
12C3053
LOGO
12C3062
Control Statement

The order in which statements are executed in a program is
called the flow of control. In a sense, the computer is under the
control of one statement at a time. When a statement has been
executed, control is turned over to the next statement (like a
baton being passed in a relay race). Flow of control is normally
sequential. That is, when one statement is finished executing,
control passes to the next statement in the pro- gram. If we
want the flow of control to be nonsequential, you can use
control structure.

Company Logo
Control Flow
In a program, statements may be executed sequentially, selectively or iteratively.
Every programming language provides constructs to support sequence, selection
or iteration. So there are three types of programming constructs :

 Sequence


Functions and Procedures

 Selection



If...Then...Else statement
Select Case statement

 Iterative




Company Logo

For...Next Loop statement
Do...Loop statement
Sequential Construct

The sequential construct means the statements are being
executed sequentially. This represents the default flow of
statements.

Statement 1
Statement 2
Statement 3
Selection Construct
The selection construct means the execution of statement(s) depending upon the
condition-test. If a condition evaluates to true, a course-of-action (a set of statements)
is followed otherwise another course-of-action is followed. This construct is also
called decision construct as it helps in decision making.
Condition
?

true

Statement 1

false

One course-of-action

Statement 1
Another course
of action
Statement 2

Statement 2
If...Then...Else statement
Perhaps the most important statement in a program is the If statement and then its
statements. In other words
If.. Then.. Else statement provides an alternate choice to the user i.e. if the
condition is true then a set of statements are executed otherwise another set of
statements are executed.
In Visual Basic we use three types of ‘IF’ statements:
1. Simple If
2. If Else
3. Nested If
If...Then...Else statement

Syntax :

true

If (boolean Expression) Then
VB Statement(s)
Else
VB Statement(s)
End If

Statement

Condition
?

false

Statement
Select Case statement
If we have a lot of conditional statements, using If..Then..Else could be very
messy. For multiple conditional statements, it is better to use Select Case or
Select Case allows multi way branching through the code.

Syntax :
Select Case expression ‘expression maybe string or numeric
Case value1
Block of one or more VB statements
Case value2
Block of one or more VB Statements
Case value3
Block of one or more VB statements
Case value4
.
.
.
Case Else
Block of one or more VB Statements
End Select
Select Case statement

Case 1

true

Case 1 Statements

false
Case 2

true

Case 2 Statements

false

Case N

true

Case Else Statements

Case N Statements
Iterative Constructs
The iterative or repetitive constructs means repetition of a set-of-statements
depending upon a condition-test. A set-of-statements are repeated again and
again till the condition or Boolean Expression evaluates to true. The iteration
constructs are also called as looping constructs.
false
The exit condition

Condition
?

True

Statement 1
The loop
body

Statement 2
For...Next Loop statement
Repeats a group of statements a specified number of times.

Syntax :
For counter [ As datatype ] = start To end [ Step step ]
[ statements ]
[ Continue For ]
[ statements ]
[ Exit For ]
[ statements ]
Next [ counter ]
Do...Loop statement
Repeats a block of statements while a Boolean condition is True or
until the condition becomes True.

Syntax :
Do { While | Until } condition
[ statements ]
[ Continue Do ]
[ statements ]
[ Exit Do ]
[ statements ]
Loop
-orDo
[ statements ]
[ Continue Do ]
[ statements ]
[ Exit Do ]
[ statements ]
Loop { While | Until } condition
Thank You.....

Contenu connexe

Tendances

Creating a data report in visual basic 6
Creating a data report in visual basic 6Creating a data report in visual basic 6
Creating a data report in visual basic 6
mrgulshansharma
 
Control Structures
Control StructuresControl Structures
Control Structures
Ghaffar Khan
 
Decision statements in vb.net
Decision statements in vb.netDecision statements in vb.net
Decision statements in vb.net
ilakkiya
 
Chapter 5 - Operators in C++
Chapter 5 - Operators in C++Chapter 5 - Operators in C++
Chapter 5 - Operators in C++
Deepak Singh
 

Tendances (20)

Creating a data report in visual basic 6
Creating a data report in visual basic 6Creating a data report in visual basic 6
Creating a data report in visual basic 6
 
Control Structures
Control StructuresControl Structures
Control Structures
 
Vb decision making statements
Vb decision making statementsVb decision making statements
Vb decision making statements
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handling
 
Sdi & mdi
Sdi & mdiSdi & mdi
Sdi & mdi
 
Compilers
CompilersCompilers
Compilers
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
Decision statements in vb.net
Decision statements in vb.netDecision statements in vb.net
Decision statements in vb.net
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements
 
Operators used in vb.net
Operators used in vb.netOperators used in vb.net
Operators used in vb.net
 
Symbol table in compiler Design
Symbol table in compiler DesignSymbol table in compiler Design
Symbol table in compiler Design
 
trigger dbms
trigger dbmstrigger dbms
trigger dbms
 
Error handling and debugging in vb
Error handling and debugging in vbError handling and debugging in vb
Error handling and debugging in vb
 
ADO CONTROLS - Database usage
ADO CONTROLS - Database usageADO CONTROLS - Database usage
ADO CONTROLS - Database usage
 
Control structures in C
Control structures in CControl structures in C
Control structures in C
 
Loops Basics
Loops BasicsLoops Basics
Loops Basics
 
Chapter 5 - Operators in C++
Chapter 5 - Operators in C++Chapter 5 - Operators in C++
Chapter 5 - Operators in C++
 

Similaire à Control Structures in Visual Basic

Chapter 4 flow control structures and arrays
Chapter 4 flow control structures and arraysChapter 4 flow control structures and arrays
Chapter 4 flow control structures and arrays
sshhzap
 

Similaire à Control Structures in Visual Basic (20)

Control statements
Control statementsControl statements
Control statements
 
BSc. III Unit iii VB.NET
BSc. III Unit iii VB.NETBSc. III Unit iii VB.NET
BSc. III Unit iii VB.NET
 
Chapter 4 flow control structures and arrays
Chapter 4 flow control structures and arraysChapter 4 flow control structures and arrays
Chapter 4 flow control structures and arrays
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJ
 
Control statements in java
Control statements in javaControl statements in java
Control statements in java
 
Cordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to JavascriptCordova training : Day 3 - Introduction to Javascript
Cordova training : Day 3 - Introduction to Javascript
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlan
 
Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
 
web presentation 138.pptx
web presentation 138.pptxweb presentation 138.pptx
web presentation 138.pptx
 
Constructs (Programming Methodology)
Constructs (Programming Methodology)Constructs (Programming Methodology)
Constructs (Programming Methodology)
 
slides03.ppt
slides03.pptslides03.ppt
slides03.ppt
 
Introduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow controlIntroduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow control
 
Flow of control
Flow of controlFlow of control
Flow of control
 
Java input Scanner
Java input Scanner Java input Scanner
Java input Scanner
 
VB PPT by ADI PART3.pdf
VB PPT by ADI PART3.pdfVB PPT by ADI PART3.pdf
VB PPT by ADI PART3.pdf
 
VB PPT by ADI PART3.pdf
VB PPT by ADI PART3.pdfVB PPT by ADI PART3.pdf
VB PPT by ADI PART3.pdf
 
Vb script tutorial
Vb script tutorialVb script tutorial
Vb script tutorial
 
Java Decision Control
Java Decision ControlJava Decision Control
Java Decision Control
 
Computer programming 2 Lesson 9
Computer programming 2  Lesson 9Computer programming 2  Lesson 9
Computer programming 2 Lesson 9
 

Dernier

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Dernier (20)

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 

Control Structures in Visual Basic

  • 1. Control Structures In Visual Basic Submitted By: Sakar Chiolunkar Shashank Baghel Tushar jain 12C3045 12C3053 LOGO 12C3062
  • 2. Control Statement The order in which statements are executed in a program is called the flow of control. In a sense, the computer is under the control of one statement at a time. When a statement has been executed, control is turned over to the next statement (like a baton being passed in a relay race). Flow of control is normally sequential. That is, when one statement is finished executing, control passes to the next statement in the pro- gram. If we want the flow of control to be nonsequential, you can use control structure. Company Logo
  • 3. Control Flow In a program, statements may be executed sequentially, selectively or iteratively. Every programming language provides constructs to support sequence, selection or iteration. So there are three types of programming constructs :  Sequence  Functions and Procedures  Selection   If...Then...Else statement Select Case statement  Iterative   Company Logo For...Next Loop statement Do...Loop statement
  • 4. Sequential Construct The sequential construct means the statements are being executed sequentially. This represents the default flow of statements. Statement 1 Statement 2 Statement 3
  • 5. Selection Construct The selection construct means the execution of statement(s) depending upon the condition-test. If a condition evaluates to true, a course-of-action (a set of statements) is followed otherwise another course-of-action is followed. This construct is also called decision construct as it helps in decision making. Condition ? true Statement 1 false One course-of-action Statement 1 Another course of action Statement 2 Statement 2
  • 6. If...Then...Else statement Perhaps the most important statement in a program is the If statement and then its statements. In other words If.. Then.. Else statement provides an alternate choice to the user i.e. if the condition is true then a set of statements are executed otherwise another set of statements are executed. In Visual Basic we use three types of ‘IF’ statements: 1. Simple If 2. If Else 3. Nested If
  • 7. If...Then...Else statement Syntax : true If (boolean Expression) Then VB Statement(s) Else VB Statement(s) End If Statement Condition ? false Statement
  • 8. Select Case statement If we have a lot of conditional statements, using If..Then..Else could be very messy. For multiple conditional statements, it is better to use Select Case or Select Case allows multi way branching through the code. Syntax : Select Case expression ‘expression maybe string or numeric Case value1 Block of one or more VB statements Case value2 Block of one or more VB Statements Case value3 Block of one or more VB statements Case value4 . . . Case Else Block of one or more VB Statements End Select
  • 9. Select Case statement Case 1 true Case 1 Statements false Case 2 true Case 2 Statements false Case N true Case Else Statements Case N Statements
  • 10. Iterative Constructs The iterative or repetitive constructs means repetition of a set-of-statements depending upon a condition-test. A set-of-statements are repeated again and again till the condition or Boolean Expression evaluates to true. The iteration constructs are also called as looping constructs. false The exit condition Condition ? True Statement 1 The loop body Statement 2
  • 11. For...Next Loop statement Repeats a group of statements a specified number of times. Syntax : For counter [ As datatype ] = start To end [ Step step ] [ statements ] [ Continue For ] [ statements ] [ Exit For ] [ statements ] Next [ counter ]
  • 12. Do...Loop statement Repeats a block of statements while a Boolean condition is True or until the condition becomes True. Syntax : Do { While | Until } condition [ statements ] [ Continue Do ] [ statements ] [ Exit Do ] [ statements ] Loop -orDo [ statements ] [ Continue Do ] [ statements ] [ Exit Do ] [ statements ] Loop { While | Until } condition