SlideShare a Scribd company logo
1 of 18
control structure in visual basic
SESSION:-2023-24
I N D E X
Introduction to Control Structure
Control Structure are used to control the
flow of program’s execution. By default control
structure in a program are executed sequentially.
There are two types of control structure:-
 Decision-making Statement
 LOOPING STATEMENT0
There are four types of decision making
statement:-
(1) Simple if statement
(2) If-else statement
(3) Nested if statement
(4) Select case statement
SIMPLE IF STATEMENT
There is only one condition in the program, then
simple if statement is used.It has only the true block
of the statement.
Syntax:-
If(Condition) then
Statement block
End If
Example:-
If(average>40) then
MsgBox”Passed”
End If
The if else statement works like that of simple if statement. With the
difference that if you want to execute the false block differently then
if else statement is used.In this type of statement you can have one
block corresponding to the true condition and the other block
corresponding to the false condition.
Syntex:-
if(Condition) then
Statement block-1
Else
Statement block-2
End If
Example:-
If(average>40) then
MsgBox “Passed’
Else
MsgBox “Failed”
End If
NESTED IF STATEMENT
If you have more then two condition to be tested then another if statement is used in else part of the if
statement it is called nesting.
Syntex;-
If(Condition-1) then
Statement block-1
Else
If(Condition-2) then
Statement block-2
Else
If(Condition-3) then
Statement block-3
-
-
Else
Satement block-n
End If
End If
End If
END SUB
Dim average As Integer
average = Val(Text1.Text)
If (average > 75) Then
printf = "A"
Else
If (average > 65) Then
printf = "B"
Else
If (average > 55) Then
printf = "C"
Else
If (average > 45) Then
printf = "S"
Else
printf = "F"
End If
End If
End If
End If
End Sub
Example:-
SELECT CASE STATEMENT
The select case statement is used as an alternative of if then else for selectively
Executing one block of statement from among multiple block of statement.
Syntex:-
Select case Expression
Case Expression-1
Statement block-1
Case Expression-2
Statement block-2
-
-
-
Case Else
Statement block-n
End select
Conti....2...
Example:-
days = Val(Text1.text)
If Val(Text1.text) = 1 Then
MsgBox "Sunday"
Else
If Val(Text1.text) = 2 Then
MsgBox "Monday"
Else
If Val(Text1.text) = 3 Then
MsgBox "Tuesday"
Else
If Val(Text1.text) = 4 Then
MsgBox "Wednesday"
Else
If Val(Text1.text) = 5 Then
MsgBox "Thursday"
Else
If Val(Text1.text) = 6 Then
MsgBox "Friday"
Else
If Val(Text1.text) = 7 Then
MsgBox "Saturday"
Else
MsgBox "not weakday"
End If
End If
End If
End If
End If
End If
Looping Satetment
There are six type of looping statement in visual basic:-
(1)While wend loop
(2)Do while loop
(3)Do untill loop
(4)Do loop until
(5)For next loop
(6)For each... next loop
While wend loop:-
While wend loop execute a block of statement while condition is
true.
Syntex:-
While(Condition) then
Statement block
Wend
Example:-
Dim num as Integer
Num=0
While(num<=10)
Print num
Num=num+1
Wend
DO WHILE LOOP
Do while loop is exit control loop. Do while works with
comparison expression just as the if statement does.
Syntex:-
Do while(Condition) then
Statement block
Loop
Example:-
Dim i As Integer
i=0
Do while(i<10)
Print i
i=i+1
loop
DO UNTIL LOOP
Do while loop continues executing the body of the loop as long as
the comparision test is true.But do until loop executes the body
of the loop as long as the comparision test is false.
Syntex:-
Do until (Condition)
Statement block
Loop
Example:-
Dim i As Integer
i=0
Do until (i>10)
Print i
i=i+1
loop
The loop continues until the loop until statement. The comparision test
appears at the bottom of the loop. Hence, the body of the loop always
executes atleast once.The body of the loop executes more than once as long
as the comparision test stayes false.
Syntex:-
Do
Statement block
Loop until (Condition)
Example:-
Dim i As Integer
i=0
Do
Print i
i=i+1
loop until (i>10)
The for loop repeats for a specific number of
times.Hence,for is a Keyword, counter is a variable name &
value1,value2 are integer values. The block of statement
should be a valid VB statement.
Syntex:-
For counter=value1 To value2
Statement block
Next Counter
Example:-
For i=1 to 10
Print i
Next i
FOR EACH.....NEXT LOOP
For each...next loop repeats a group of statement for each
element in a collection of objects or in an array instead of
repeating the statement a specified number of time.(Collection
can be of objects or arrays)
Syntex:-
For Each object/array
VB statement
Next
Example:-
For each element in group
VB statement
Next element
CONTROL STRUCTURE IN VB

More Related Content

What's hot

Unit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programmingUnit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programmingAbha Damani
 
Exception Handling in VB.Net
Exception Handling in VB.NetException Handling in VB.Net
Exception Handling in VB.Netrishisingh190
 
VB Function and procedure
VB Function and procedureVB Function and procedure
VB Function and procedurepragya ratan
 
Control Structures in Python
Control Structures in PythonControl Structures in Python
Control Structures in PythonSumit Satam
 
Visual Basic IDE Introduction
Visual Basic IDE IntroductionVisual Basic IDE Introduction
Visual Basic IDE IntroductionAhllen Javier
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivityTanmoy Barman
 
Object Oriented Programming with C#
Object Oriented Programming with C#Object Oriented Programming with C#
Object Oriented Programming with C#SyedUmairAli9
 
Looping statement in vb.net
Looping statement in vb.netLooping statement in vb.net
Looping statement in vb.netilakkiya
 
Advanced Operating System Lecture Notes
Advanced Operating System Lecture NotesAdvanced Operating System Lecture Notes
Advanced Operating System Lecture NotesAnirudhan Guru
 

What's hot (20)

Unit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programmingUnit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programming
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Exception Handling in VB.Net
Exception Handling in VB.NetException Handling in VB.Net
Exception Handling in VB.Net
 
Visual basic
Visual basicVisual basic
Visual basic
 
VB Function and procedure
VB Function and procedureVB Function and procedure
VB Function and procedure
 
Control Structures in Python
Control Structures in PythonControl Structures in Python
Control Structures in Python
 
Windowforms controls c#
Windowforms controls c#Windowforms controls c#
Windowforms controls c#
 
Cohesion and coupling
Cohesion and couplingCohesion and coupling
Cohesion and coupling
 
Program control statements in c#
Program control statements in c#Program control statements in c#
Program control statements in c#
 
Visual Basic IDE Introduction
Visual Basic IDE IntroductionVisual Basic IDE Introduction
Visual Basic IDE Introduction
 
Meaning Of VB
Meaning Of VBMeaning Of VB
Meaning Of VB
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
Basic concept of OOP's
Basic concept of OOP'sBasic concept of OOP's
Basic concept of OOP's
 
Visual Basic 6.0
Visual Basic 6.0Visual Basic 6.0
Visual Basic 6.0
 
Object Oriented Programming with C#
Object Oriented Programming with C#Object Oriented Programming with C#
Object Oriented Programming with C#
 
Looping statement in vb.net
Looping statement in vb.netLooping statement in vb.net
Looping statement in vb.net
 
Introduction to .NET Framework
Introduction to .NET FrameworkIntroduction to .NET Framework
Introduction to .NET Framework
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Advanced Operating System Lecture Notes
Advanced Operating System Lecture NotesAdvanced Operating System Lecture Notes
Advanced Operating System Lecture Notes
 
Pseudocode
PseudocodePseudocode
Pseudocode
 

Similar to CONTROL STRUCTURE IN VB

BSc. III Unit iii VB.NET
BSc. III Unit iii VB.NETBSc. III Unit iii VB.NET
BSc. III Unit iii VB.NETUjwala Junghare
 
Unit IV Array in VB.Net.pptx
Unit IV Array in VB.Net.pptxUnit IV Array in VB.Net.pptx
Unit IV Array in VB.Net.pptxUjwala Junghare
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statementsSaad Sheikh
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJTANUJ ⠀
 
Constructs (Programming Methodology)
Constructs (Programming Methodology)Constructs (Programming Methodology)
Constructs (Programming Methodology)Jyoti Bhardwaj
 
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 controlENGWAU TONNY
 
Control structures ii
Control structures ii Control structures ii
Control structures ii Ahmad Idrees
 
03 conditions loops
03   conditions loops03   conditions loops
03 conditions loopsManzoor ALam
 
Control statements
Control statementsControl statements
Control statementsCutyChhaya
 
Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlanDeepak Lakhlan
 
Learn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & LoopsLearn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & LoopsEng Teong Cheah
 
Decision statements
Decision statementsDecision statements
Decision statementsJaya Kumari
 

Similar to CONTROL STRUCTURE IN VB (20)

BSc. III Unit iii VB.NET
BSc. III Unit iii VB.NETBSc. III Unit iii VB.NET
BSc. III Unit iii VB.NET
 
Unit IV Array in VB.Net.pptx
Unit IV Array in VB.Net.pptxUnit IV Array in VB.Net.pptx
Unit IV Array in VB.Net.pptx
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJ
 
Constructs (Programming Methodology)
Constructs (Programming Methodology)Constructs (Programming Methodology)
Constructs (Programming Methodology)
 
Comp ppt (1)
Comp ppt (1)Comp ppt (1)
Comp ppt (1)
 
Loops and iteration.docx
Loops and iteration.docxLoops and iteration.docx
Loops and iteration.docx
 
C++ chapter 4
C++ chapter 4C++ chapter 4
C++ chapter 4
 
Do...Loop
Do...LoopDo...Loop
Do...Loop
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
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
 
Control structures ii
Control structures ii Control structures ii
Control structures ii
 
03 conditions loops
03   conditions loops03   conditions loops
03 conditions loops
 
Control statements
Control statementsControl statements
Control statements
 
Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlan
 
Flow of Control
Flow of ControlFlow of Control
Flow of Control
 
Python Control Structures.pptx
Python Control Structures.pptxPython Control Structures.pptx
Python Control Structures.pptx
 
07 flow control
07   flow control07   flow control
07 flow control
 
Learn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & LoopsLearn C# Programming - Decision Making & Loops
Learn C# Programming - Decision Making & Loops
 
Decision statements
Decision statementsDecision statements
Decision statements
 

More from classall

E -COMMERCE.ppt
E -COMMERCE.pptE -COMMERCE.ppt
E -COMMERCE.pptclassall
 
operat in vb .pptx
operat in vb .pptxoperat in vb .pptx
operat in vb .pptxclassall
 
Tally_Tutor_1.ppt
Tally_Tutor_1.pptTally_Tutor_1.ppt
Tally_Tutor_1.pptclassall
 
networking
networking networking
networking classall
 
introduction to e-commerce.pptx
introduction to e-commerce.pptxintroduction to e-commerce.pptx
introduction to e-commerce.pptxclassall
 
E-Rdiagram.ppt
E-Rdiagram.pptE-Rdiagram.ppt
E-Rdiagram.pptclassall
 
EDI presentation.pptx
EDI presentation.pptxEDI presentation.pptx
EDI presentation.pptxclassall
 
control structure in visual basic
control structure in visual basic control structure in visual basic
control structure in visual basic classall
 
b,Sc it data structure.ppt
b,Sc it data structure.pptb,Sc it data structure.ppt
b,Sc it data structure.pptclassall
 
SAVE WATER SAVE LIFE
SAVE WATER SAVE LIFESAVE WATER SAVE LIFE
SAVE WATER SAVE LIFEclassall
 
MULTIMEDIA
MULTIMEDIAMULTIMEDIA
MULTIMEDIAclassall
 
GEETA2.pptx
GEETA2.pptxGEETA2.pptx
GEETA2.pptxclassall
 
GEETA1.pptx
GEETA1.pptxGEETA1.pptx
GEETA1.pptxclassall
 
GEETA.pptx
GEETA.pptxGEETA.pptx
GEETA.pptxclassall
 
राष्ट्रीय एकता 13.3.18.ppt
राष्ट्रीय एकता 13.3.18.pptराष्ट्रीय एकता 13.3.18.ppt
राष्ट्रीय एकता 13.3.18.pptclassall
 
b,Sc it data structure.pptx
b,Sc it data structure.pptxb,Sc it data structure.pptx
b,Sc it data structure.pptxclassall
 
MEMORY NOTES.pptx
MEMORY NOTES.pptxMEMORY NOTES.pptx
MEMORY NOTES.pptxclassall
 
HINDI MEMORY NOTES
HINDI MEMORY NOTESHINDI MEMORY NOTES
HINDI MEMORY NOTESclassall
 

More from classall (20)

E -COMMERCE.ppt
E -COMMERCE.pptE -COMMERCE.ppt
E -COMMERCE.ppt
 
operat in vb .pptx
operat in vb .pptxoperat in vb .pptx
operat in vb .pptx
 
Tally_Tutor_1.ppt
Tally_Tutor_1.pptTally_Tutor_1.ppt
Tally_Tutor_1.ppt
 
networking
networking networking
networking
 
introduction to e-commerce.pptx
introduction to e-commerce.pptxintroduction to e-commerce.pptx
introduction to e-commerce.pptx
 
E-Rdiagram.ppt
E-Rdiagram.pptE-Rdiagram.ppt
E-Rdiagram.ppt
 
EDI presentation.pptx
EDI presentation.pptxEDI presentation.pptx
EDI presentation.pptx
 
control structure in visual basic
control structure in visual basic control structure in visual basic
control structure in visual basic
 
b,Sc it data structure.ppt
b,Sc it data structure.pptb,Sc it data structure.ppt
b,Sc it data structure.ppt
 
SAVE WATER SAVE LIFE
SAVE WATER SAVE LIFESAVE WATER SAVE LIFE
SAVE WATER SAVE LIFE
 
MS OFFICE
MS OFFICEMS OFFICE
MS OFFICE
 
MULTIMEDIA
MULTIMEDIAMULTIMEDIA
MULTIMEDIA
 
GEETA2.pptx
GEETA2.pptxGEETA2.pptx
GEETA2.pptx
 
GEETA1.pptx
GEETA1.pptxGEETA1.pptx
GEETA1.pptx
 
GEETA.pptx
GEETA.pptxGEETA.pptx
GEETA.pptx
 
राष्ट्रीय एकता 13.3.18.ppt
राष्ट्रीय एकता 13.3.18.pptराष्ट्रीय एकता 13.3.18.ppt
राष्ट्रीय एकता 13.3.18.ppt
 
mmu.pptx
mmu.pptxmmu.pptx
mmu.pptx
 
b,Sc it data structure.pptx
b,Sc it data structure.pptxb,Sc it data structure.pptx
b,Sc it data structure.pptx
 
MEMORY NOTES.pptx
MEMORY NOTES.pptxMEMORY NOTES.pptx
MEMORY NOTES.pptx
 
HINDI MEMORY NOTES
HINDI MEMORY NOTESHINDI MEMORY NOTES
HINDI MEMORY NOTES
 

Recently uploaded

Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 

Recently uploaded (20)

Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 

CONTROL STRUCTURE IN VB

  • 1. control structure in visual basic SESSION:-2023-24
  • 2. I N D E X
  • 3. Introduction to Control Structure Control Structure are used to control the flow of program’s execution. By default control structure in a program are executed sequentially. There are two types of control structure:-  Decision-making Statement  LOOPING STATEMENT0
  • 4. There are four types of decision making statement:- (1) Simple if statement (2) If-else statement (3) Nested if statement (4) Select case statement
  • 5. SIMPLE IF STATEMENT There is only one condition in the program, then simple if statement is used.It has only the true block of the statement. Syntax:- If(Condition) then Statement block End If Example:- If(average>40) then MsgBox”Passed” End If
  • 6. The if else statement works like that of simple if statement. With the difference that if you want to execute the false block differently then if else statement is used.In this type of statement you can have one block corresponding to the true condition and the other block corresponding to the false condition. Syntex:- if(Condition) then Statement block-1 Else Statement block-2 End If Example:- If(average>40) then MsgBox “Passed’ Else MsgBox “Failed” End If
  • 7. NESTED IF STATEMENT If you have more then two condition to be tested then another if statement is used in else part of the if statement it is called nesting. Syntex;- If(Condition-1) then Statement block-1 Else If(Condition-2) then Statement block-2 Else If(Condition-3) then Statement block-3 - - Else Satement block-n End If End If End If END SUB
  • 8. Dim average As Integer average = Val(Text1.Text) If (average > 75) Then printf = "A" Else If (average > 65) Then printf = "B" Else If (average > 55) Then printf = "C" Else If (average > 45) Then printf = "S" Else printf = "F" End If End If End If End If End Sub Example:-
  • 9. SELECT CASE STATEMENT The select case statement is used as an alternative of if then else for selectively Executing one block of statement from among multiple block of statement. Syntex:- Select case Expression Case Expression-1 Statement block-1 Case Expression-2 Statement block-2 - - - Case Else Statement block-n End select Conti....2...
  • 10. Example:- days = Val(Text1.text) If Val(Text1.text) = 1 Then MsgBox "Sunday" Else If Val(Text1.text) = 2 Then MsgBox "Monday" Else If Val(Text1.text) = 3 Then MsgBox "Tuesday" Else If Val(Text1.text) = 4 Then MsgBox "Wednesday" Else If Val(Text1.text) = 5 Then MsgBox "Thursday" Else If Val(Text1.text) = 6 Then MsgBox "Friday" Else If Val(Text1.text) = 7 Then MsgBox "Saturday" Else MsgBox "not weakday" End If End If End If End If End If End If
  • 11. Looping Satetment There are six type of looping statement in visual basic:- (1)While wend loop (2)Do while loop (3)Do untill loop (4)Do loop until (5)For next loop (6)For each... next loop
  • 12. While wend loop:- While wend loop execute a block of statement while condition is true. Syntex:- While(Condition) then Statement block Wend Example:- Dim num as Integer Num=0 While(num<=10) Print num Num=num+1 Wend
  • 13. DO WHILE LOOP Do while loop is exit control loop. Do while works with comparison expression just as the if statement does. Syntex:- Do while(Condition) then Statement block Loop Example:- Dim i As Integer i=0 Do while(i<10) Print i i=i+1 loop
  • 14. DO UNTIL LOOP Do while loop continues executing the body of the loop as long as the comparision test is true.But do until loop executes the body of the loop as long as the comparision test is false. Syntex:- Do until (Condition) Statement block Loop Example:- Dim i As Integer i=0 Do until (i>10) Print i i=i+1 loop
  • 15. The loop continues until the loop until statement. The comparision test appears at the bottom of the loop. Hence, the body of the loop always executes atleast once.The body of the loop executes more than once as long as the comparision test stayes false. Syntex:- Do Statement block Loop until (Condition) Example:- Dim i As Integer i=0 Do Print i i=i+1 loop until (i>10)
  • 16. The for loop repeats for a specific number of times.Hence,for is a Keyword, counter is a variable name & value1,value2 are integer values. The block of statement should be a valid VB statement. Syntex:- For counter=value1 To value2 Statement block Next Counter Example:- For i=1 to 10 Print i Next i
  • 17. FOR EACH.....NEXT LOOP For each...next loop repeats a group of statement for each element in a collection of objects or in an array instead of repeating the statement a specified number of time.(Collection can be of objects or arrays) Syntex:- For Each object/array VB statement Next Example:- For each element in group VB statement Next element