SlideShare a Scribd company logo
Conditional Statement IF Condition   Syntax for If Condition If (Condition) Then Statement ………. Else   Statement ………. Example Dim percentage As Integer WriteLine("Enter the percentage") percentage = Val(ReadLine()) If percentage >= 75 Then WriteLine("Qualified for sitting examination") Else WriteLine("Not Qualified for sitting examination") End If Read()
If Condition & Select Case Statement The first line contains our condition: "If the following condition is met".  The second line is what we want to do if the condition is indeed met. The third line tells Visual Basic that the If statement ends right here. Select....Case Statement  The Select Case statement executes one of several groups of statements depending on the value of an expression. If your code has the capability to handle different values of a particular variable then you can use a Select Case statement. You use Select Case to test an expression, determine which of the given cases it matches and execute the code in that matched case. The syntax of the Select Case statement looks like this:  Select Case testexpression     [Case expressionlist-n         [statements-n]] . . .     [Case Else elsestatements] End Select
Select Case Statement Example   Imports System.Console Dim keyIn As Integer WriteLine("Enter a number between 1 and 4")  keyIn = Val(ReadLine()) Select Case keyIn Case 1 WriteLine("You entered 1") Case 2 WriteLine("You entered 2") Case 3 WriteLine("You entered 3") Case 4 WriteLine("You entered 4") End Select
Loops in VB.Net For LOOP The For loop is the most popular loop. For loops enable us to execute a series of expressions multiple numbers of times. The For loop in VB .NET needs a loop index which counts the number of loop iterations as the loop executes. The syntax for the For loop looks like this:  Syntax for FOR LOOP For index=start to end[Step step] [statements] [Exit For] [statements] Next[index]
Loops in VB.Net Example on For loop  Module Module1 Sub Main() Dim d As Integer For d = 0 To 2 System.Console.WriteLine("In the For Loop") Next d End Sub End Module  While loop  While loop keeps executing until the condition against which it tests remain true.  The syntax of while loop looks like this:  While condition [statements] End While
Loops in VB.Net Example on For loop  Module Module1 Sub Main() Dim d As Integer For d = 0 To 2 System.Console.WriteLine("In the For Loop") Next d End Sub End Module  While loop  While loop keeps executing until the condition against which it tests remain true.  The syntax of while loop looks like this:  While condition [statements] End While
Loops in VB.Net Example for While Loop ‘ Imports System.Console Module Module1 Sub Main() Dim e As Integer While e <= 3 e = e + 1 System.Console.WriteLine(&quot;The Loop ran &quot; & e & &quot;times&quot;) End While Read() End Sub End Module
Loops in VB.Net Do Loop  The Do loop can be used to execute a fixed block of statements indefinite number of times. The Do loop keeps executing it's statements while or until the condition is true. Two keywords, while and until can be used with the do loop. The Do loop also supports an Exit Do statement which makes the loop to exit at any moment.  The syntax of Do loop looks like this:  Do[{while | Until} condition] [statements] [Exit Do] [statements] Loop
Loops in VB.Net Example on Do loop  Module Module1 Sub Main() Dim str As String Do Until str = &quot;Cool&quot; System.Console.WriteLine(&quot;What to do?&quot;) str = System.Console.ReadLine() Loop End Sub End Module

More Related Content

PPT
ppt on scanner class
DOCX
Bitstuffing
DOCX
Write and write line methods
PPT
C# basics
PPTX
C# Tutorial
PPSX
C# - Part 1
PPTX
java in Aartificial intelligent by virat andodariya
ppt on scanner class
Bitstuffing
Write and write line methods
C# basics
C# Tutorial
C# - Part 1
java in Aartificial intelligent by virat andodariya

What's hot (18)

PDF
Introduction to c first week slides
PPTX
The Little Wonders of C# 6
PDF
Apple’s New Swift Programming Language Takes Flight With New Enhancements And...
PDF
OOPS With CSharp - Jinal Desai .NET
PPT
C# features
PPTX
PPTX
Conditions In C# C-Sharp
PPTX
C language (Part 2)
PDF
overview of c#
PDF
PDF
Xtext: code generation
PPT
Basic input-output-v.1.1
PPTX
Test driven development
PPTX
Chapter one
PPTX
C# lecture 2: Literals , Variables and Data Types in C#
PPTX
if, while and for in Python
PPTX
Functional programming in TypeScript
Introduction to c first week slides
The Little Wonders of C# 6
Apple’s New Swift Programming Language Takes Flight With New Enhancements And...
OOPS With CSharp - Jinal Desai .NET
C# features
Conditions In C# C-Sharp
C language (Part 2)
overview of c#
Xtext: code generation
Basic input-output-v.1.1
Test driven development
Chapter one
C# lecture 2: Literals , Variables and Data Types in C#
if, while and for in Python
Functional programming in TypeScript
Ad

Viewers also liked (20)

PPTX
Total service management
PPT
Ergonomics
PPT
PPSX
product analysis & development- sourcing
PPTX
Product Analysis & Development
PPTX
Professional practices
PPT
Supply chain management
DOCX
Human resource management
DOCX
Customer relationship management
PPS
E smartx.ppt
PDF
Calculator code
PDF
Rajeev oops 2nd march
PDF
P 10 p-4ac756g50(gb )
PPT
Supply chain management
DOC
RECENT TRENDS OF MAINTENANCE MANAGEMENT
PDF
Inventory management
PPTX
Lean- automobile
PDF
Declaring friend function with inline code
PDF
INVENTORY OPTIMIZATION
Total service management
Ergonomics
product analysis & development- sourcing
Product Analysis & Development
Professional practices
Supply chain management
Human resource management
Customer relationship management
E smartx.ppt
Calculator code
Rajeev oops 2nd march
P 10 p-4ac756g50(gb )
Supply chain management
RECENT TRENDS OF MAINTENANCE MANAGEMENT
Inventory management
Lean- automobile
Declaring friend function with inline code
INVENTORY OPTIMIZATION
Ad

Similar to Vb (2) (20)

PPTX
BSc. III Unit iii VB.NET
PPTX
Looping statements
PPTX
Unit IV Array in VB.Net.pptx
PDF
Conditional Statements & Loops
PPTX
CONTROL STRUCTURE IN VB
PPTX
Vb.net (loop structure)
PDF
PPTX
Data structures vb
PPT
05 control structures 2
PPTX
Looping statement in vb.net
PPTX
Advanced VB: Review of the basics
PPTX
Advanced VB: Review of the basics
PPTX
Loop control statements
DOC
Conditional statements in vb script
PDF
Loops in Visual Basic Programming
PPTX
VB(unit1).pptx
PDF
VB PPT by ADI PART3.pdf
PDF
VB PPT by ADI PART3.pdf
DOCX
VBS control structures for if do whilw.docx
PPT
03 intro to vb programming
BSc. III Unit iii VB.NET
Looping statements
Unit IV Array in VB.Net.pptx
Conditional Statements & Loops
CONTROL STRUCTURE IN VB
Vb.net (loop structure)
Data structures vb
05 control structures 2
Looping statement in vb.net
Advanced VB: Review of the basics
Advanced VB: Review of the basics
Loop control statements
Conditional statements in vb script
Loops in Visual Basic Programming
VB(unit1).pptx
VB PPT by ADI PART3.pdf
VB PPT by ADI PART3.pdf
VBS control structures for if do whilw.docx
03 intro to vb programming

More from Rajeev Sharan (15)

PDF
Graduation Project (SA 8000 & it's frame work for Indian Apparel Manufacturing)
PDF
Final pl doc
PPT
Production module-ERP
PDF
Maintenance management
PPTX
Maintenance management
PPSX
Maintenance management
DOC
PAD FINAL DOC
PDF
Shirt spec sheet
DOCX
Ergonomics
PPT
Report writing.....
PPTX
Business ethics @ tata
PPTX
Software maintenance
PPT
Software quality assurance
DOC
SETTING UP OF A GARMENT INDUSTRY
PDF
Graduation Project (SA 8000 & it's frame work for Indian Apparel Manufacturing)
Final pl doc
Production module-ERP
Maintenance management
Maintenance management
Maintenance management
PAD FINAL DOC
Shirt spec sheet
Ergonomics
Report writing.....
Business ethics @ tata
Software maintenance
Software quality assurance
SETTING UP OF A GARMENT INDUSTRY

Recently uploaded (20)

PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PDF
Computing-Curriculum for Schools in Ghana
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PDF
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
IGGE1 Understanding the Self1234567891011
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
Lesson notes of climatology university.
PDF
Classroom Observation Tools for Teachers
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
Unit 4 Skeletal System.ppt.pptxopresentatiom
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Computing-Curriculum for Schools in Ghana
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
Final Presentation General Medicine 03-08-2024.pptx
IGGE1 Understanding the Self1234567891011
Chinmaya Tiranga quiz Grand Finale.pdf
Lesson notes of climatology university.
Classroom Observation Tools for Teachers
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Unit 4 Skeletal System.ppt.pptxopresentatiom
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Paper A Mock Exam 9_ Attempt review.pdf.
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc

Vb (2)

  • 1. Conditional Statement IF Condition Syntax for If Condition If (Condition) Then Statement ………. Else Statement ………. Example Dim percentage As Integer WriteLine(&quot;Enter the percentage&quot;) percentage = Val(ReadLine()) If percentage >= 75 Then WriteLine(&quot;Qualified for sitting examination&quot;) Else WriteLine(&quot;Not Qualified for sitting examination&quot;) End If Read()
  • 2. If Condition & Select Case Statement The first line contains our condition: &quot;If the following condition is met&quot;. The second line is what we want to do if the condition is indeed met. The third line tells Visual Basic that the If statement ends right here. Select....Case Statement The Select Case statement executes one of several groups of statements depending on the value of an expression. If your code has the capability to handle different values of a particular variable then you can use a Select Case statement. You use Select Case to test an expression, determine which of the given cases it matches and execute the code in that matched case. The syntax of the Select Case statement looks like this: Select Case testexpression     [Case expressionlist-n         [statements-n]] . . .     [Case Else elsestatements] End Select
  • 3. Select Case Statement Example Imports System.Console Dim keyIn As Integer WriteLine(&quot;Enter a number between 1 and 4&quot;) keyIn = Val(ReadLine()) Select Case keyIn Case 1 WriteLine(&quot;You entered 1&quot;) Case 2 WriteLine(&quot;You entered 2&quot;) Case 3 WriteLine(&quot;You entered 3&quot;) Case 4 WriteLine(&quot;You entered 4&quot;) End Select
  • 4. Loops in VB.Net For LOOP The For loop is the most popular loop. For loops enable us to execute a series of expressions multiple numbers of times. The For loop in VB .NET needs a loop index which counts the number of loop iterations as the loop executes. The syntax for the For loop looks like this: Syntax for FOR LOOP For index=start to end[Step step] [statements] [Exit For] [statements] Next[index]
  • 5. Loops in VB.Net Example on For loop Module Module1 Sub Main() Dim d As Integer For d = 0 To 2 System.Console.WriteLine(&quot;In the For Loop&quot;) Next d End Sub End Module While loop While loop keeps executing until the condition against which it tests remain true. The syntax of while loop looks like this: While condition [statements] End While
  • 6. Loops in VB.Net Example on For loop Module Module1 Sub Main() Dim d As Integer For d = 0 To 2 System.Console.WriteLine(&quot;In the For Loop&quot;) Next d End Sub End Module While loop While loop keeps executing until the condition against which it tests remain true. The syntax of while loop looks like this: While condition [statements] End While
  • 7. Loops in VB.Net Example for While Loop ‘ Imports System.Console Module Module1 Sub Main() Dim e As Integer While e <= 3 e = e + 1 System.Console.WriteLine(&quot;The Loop ran &quot; & e & &quot;times&quot;) End While Read() End Sub End Module
  • 8. Loops in VB.Net Do Loop The Do loop can be used to execute a fixed block of statements indefinite number of times. The Do loop keeps executing it's statements while or until the condition is true. Two keywords, while and until can be used with the do loop. The Do loop also supports an Exit Do statement which makes the loop to exit at any moment. The syntax of Do loop looks like this: Do[{while | Until} condition] [statements] [Exit Do] [statements] Loop
  • 9. Loops in VB.Net Example on Do loop Module Module1 Sub Main() Dim str As String Do Until str = &quot;Cool&quot; System.Console.WriteLine(&quot;What to do?&quot;) str = System.Console.ReadLine() Loop End Sub End Module