SlideShare une entreprise Scribd logo
1  sur  17
Data structures

    in VB.NET




                  1
Processing
Once the data has been entered into the
program, we need to “do something with it”
This is the data processing part
Most of what you want to do to it has been
done before – many times!
There are some standard “structures” that it
is useful to know about


                                               2
How a program runs
Variables have a space reserved in
memory (they are declared and initialised)
They might be given a value
The next lines in the program or part of
the program that is running are read and
executed one at a time



                                             3
Conditional statements
We might want a program to make some
choices based on the data it receives
  e.g. If intAge > 17 then…..
The full syntax in VB is:
  If condition Then
   Line of code to execute
  End If


                                        4
Conditional statements
Don‟t forget the End If!
It is also possible to add another condition,
a kind of „either or‟ choice:
   If condition Then
   Line of code to execute
  Else
   Another line of code if the above
    condition is false
  End If

                                                5
Conditional statements

Whole banks of If…Then statements can be
built up to test for various conditions
If there are many, this can get confusing and
messy
Far better in this case to use the Select Case
statement



                                                 6
Conditional statements

Syntax:
 Select Case variable
        Case possible value or range
            Line of code to execute
       Case another possible value
            Another line of code
 End Select


                                       7
Loop structures
These are used when we want lines of code to
be executed many times
How many times depends on either various
conditions being met or we might want it to
run a set number of times
There are loops for all occasions and
programmers have their favourites!



                                               8
Loop structures
If we want the loop to run a fixed number of
times, we use a For…..Next loop
This will use a variable as a counter
Syntax:
  For first value To last value
   Line of code to execute
  Next value



                                               9
For...Next example




                     10
Loop structures
If you want the loop to carry on an unspecified
number of times until a condition is met,
use a Do….While Loop
  Beware! It is possible to create loops that carry on to
  infinity
  Infinite loops aren‟t the end of world – the computer
  may crash so you might lose some unsaved work
  Pressing Ctrl + Break sometimes works to stop it




                                                            11
Loop structures
Syntax:
   Do While value=whatever
          Line of code to execute
   Loop


Or (my favourite):
   While value=whatever
          Line of code execute
   End While


                                    12
While…End While Example




                          13
Loop structures
Loops can also be nested
This is where it can get really confusing
One loop can search through one set of data
But it can be running inside another loop
This is useful where data is in a table
  One loop deals with rows
  The other deals with columns




                                              14
Loop structures
When nesting loops, it is important to get the
code looking tidy
The best way to do this is with indentation
  The section of code after the first line is tabbed in
  The last line is tabbed out




                                                          15
Code Example
This is a neat piece of code
  (of course, I wrote it )
It contains two loops – an inner and an outer
Can you try to work out what it does?




                                                16
Programming terms

In this session we have covered the three
ways that programs flow
  Sequence – running one line after another
  Selection – using conditional statements
  Iteration – using loops




                                              17

Contenu connexe

Tendances

Introduction to Parallel and Distributed Computing
Introduction to Parallel and Distributed ComputingIntroduction to Parallel and Distributed Computing
Introduction to Parallel and Distributed ComputingSayed Chhattan Shah
 
Decision making and loop in C#
Decision making and loop in C#Decision making and loop in C#
Decision making and loop in C#Prasanna Kumar SM
 
Visual Programming
Visual ProgrammingVisual Programming
Visual ProgrammingBagzzz
 
CONTROL STRUCTURE IN VB
CONTROL STRUCTURE IN VBCONTROL STRUCTURE IN VB
CONTROL STRUCTURE IN VBclassall
 
Multiprocessing -Interprocessing communication and process sunchronization,se...
Multiprocessing -Interprocessing communication and process sunchronization,se...Multiprocessing -Interprocessing communication and process sunchronization,se...
Multiprocessing -Interprocessing communication and process sunchronization,se...Neena R Krishna
 
Introduction to programming principles languages
Introduction to programming principles languagesIntroduction to programming principles languages
Introduction to programming principles languagesFrankie Jones
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements Tarun Sharma
 
Functional Programming Fundamentals
Functional Programming FundamentalsFunctional Programming Fundamentals
Functional Programming FundamentalsShahriar Hyder
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programmingNeeru Mittal
 
Exception Handling In Java
Exception Handling In JavaException Handling In Java
Exception Handling In Javaparag
 
4 evolution-of-programming-languages
4 evolution-of-programming-languages4 evolution-of-programming-languages
4 evolution-of-programming-languagesRohit Shrivastava
 
Multithreading
MultithreadingMultithreading
MultithreadingA B Shinde
 
OOP in C++
OOP in C++OOP in C++
OOP in C++ppd1961
 

Tendances (20)

Visual programming
Visual programmingVisual programming
Visual programming
 
Introduction to Parallel and Distributed Computing
Introduction to Parallel and Distributed ComputingIntroduction to Parallel and Distributed Computing
Introduction to Parallel and Distributed Computing
 
Exception handling
Exception handlingException handling
Exception handling
 
Introduction to Visual Studio.NET
Introduction to Visual Studio.NETIntroduction to Visual Studio.NET
Introduction to Visual Studio.NET
 
Decision making and loop in C#
Decision making and loop in C#Decision making and loop in C#
Decision making and loop in C#
 
Course outline of parallel and distributed computing
Course outline of parallel and distributed computingCourse outline of parallel and distributed computing
Course outline of parallel and distributed computing
 
Visual Programming
Visual ProgrammingVisual Programming
Visual Programming
 
File handling
File handlingFile handling
File handling
 
CONTROL STRUCTURE IN VB
CONTROL STRUCTURE IN VBCONTROL STRUCTURE IN VB
CONTROL STRUCTURE IN VB
 
Visual Basic 6.0
Visual Basic 6.0Visual Basic 6.0
Visual Basic 6.0
 
First and follow set
First and follow setFirst and follow set
First and follow set
 
Multiprocessing -Interprocessing communication and process sunchronization,se...
Multiprocessing -Interprocessing communication and process sunchronization,se...Multiprocessing -Interprocessing communication and process sunchronization,se...
Multiprocessing -Interprocessing communication and process sunchronization,se...
 
Introduction to programming principles languages
Introduction to programming principles languagesIntroduction to programming principles languages
Introduction to programming principles languages
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements
 
Functional Programming Fundamentals
Functional Programming FundamentalsFunctional Programming Fundamentals
Functional Programming Fundamentals
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
 
Exception Handling In Java
Exception Handling In JavaException Handling In Java
Exception Handling In Java
 
4 evolution-of-programming-languages
4 evolution-of-programming-languages4 evolution-of-programming-languages
4 evolution-of-programming-languages
 
Multithreading
MultithreadingMultithreading
Multithreading
 
OOP in C++
OOP in C++OOP in C++
OOP in C++
 

En vedette

En vedette (20)

Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 
Using loops
Using loopsUsing loops
Using loops
 
Data types vbnet
Data types vbnetData types vbnet
Data types vbnet
 
Decisions
DecisionsDecisions
Decisions
 
Simple debugging
Simple debuggingSimple debugging
Simple debugging
 
Design for edp
Design for edpDesign for edp
Design for edp
 
Software development lifecycle
Software development lifecycleSoftware development lifecycle
Software development lifecycle
 
Ch 3 event driven programming
Ch 3 event driven programmingCh 3 event driven programming
Ch 3 event driven programming
 
Ndu06 typesof language
Ndu06 typesof languageNdu06 typesof language
Ndu06 typesof language
 
Decisions
DecisionsDecisions
Decisions
 
Design documentation
Design documentationDesign documentation
Design documentation
 
Simple debugging
Simple debuggingSimple debugging
Simple debugging
 
Event driven theory
Event driven theoryEvent driven theory
Event driven theory
 
Data types vbnet
Data types vbnetData types vbnet
Data types vbnet
 
Algorithms
AlgorithmsAlgorithms
Algorithms
 
Event driven programming amazeballs
Event driven programming amazeballsEvent driven programming amazeballs
Event driven programming amazeballs
 
Controls
ControlsControls
Controls
 
Event oriented programming
Event oriented programmingEvent oriented programming
Event oriented programming
 
(WRK302) Event-Driven Programming
(WRK302) Event-Driven Programming(WRK302) Event-Driven Programming
(WRK302) Event-Driven Programming
 

Similaire à Data structures in VB.NET

Macasu, gerrell c.
Macasu, gerrell c.Macasu, gerrell c.
Macasu, gerrell c.gerrell
 
Switch case and looping new
Switch case and looping newSwitch case and looping new
Switch case and looping newaprilyyy
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!olracoatalub
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch casesMeoRamos
 
APP_Unit 1_updated.pptx
APP_Unit 1_updated.pptxAPP_Unit 1_updated.pptx
APP_Unit 1_updated.pptxgogulram2
 
(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_i(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_iNico Ludwig
 
Switch case and looping kim
Switch case and looping kimSwitch case and looping kim
Switch case and looping kimkimberly_Bm10203
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and loopingaprilyyy
 
JAVASCRIPT PPT [Autosaved].pptx
JAVASCRIPT PPT [Autosaved].pptxJAVASCRIPT PPT [Autosaved].pptx
JAVASCRIPT PPT [Autosaved].pptxAchieversITAravind
 
Full Stack Online Course in Marathahalli| AchieversIT
Full Stack Online Course in Marathahalli| AchieversITFull Stack Online Course in Marathahalli| AchieversIT
Full Stack Online Course in Marathahalli| AchieversITAchieversITAravind
 
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docxCMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docxmonicafrancis71118
 
【Unite 2017 Tokyo】パフォーマンス向上のためのスクリプトのベストプラクティス(note付き)
【Unite 2017 Tokyo】パフォーマンス向上のためのスクリプトのベストプラクティス(note付き)【Unite 2017 Tokyo】パフォーマンス向上のためのスクリプトのベストプラクティス(note付き)
【Unite 2017 Tokyo】パフォーマンス向上のためのスクリプトのベストプラクティス(note付き)Unity Technologies Japan K.K.
 
presentation_intro_to_python
presentation_intro_to_pythonpresentation_intro_to_python
presentation_intro_to_pythongunanandJha2
 

Similaire à Data structures in VB.NET (20)

My final requirement
My final requirementMy final requirement
My final requirement
 
Switch case and looping jam
Switch case and looping jamSwitch case and looping jam
Switch case and looping jam
 
Macasu, gerrell c.
Macasu, gerrell c.Macasu, gerrell c.
Macasu, gerrell c.
 
Switch case and looping new
Switch case and looping newSwitch case and looping new
Switch case and looping new
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!
 
Looping and switch cases
Looping and switch casesLooping and switch cases
Looping and switch cases
 
APP_Unit 1_updated.pptx
APP_Unit 1_updated.pptxAPP_Unit 1_updated.pptx
APP_Unit 1_updated.pptx
 
Switch case looping
Switch case loopingSwitch case looping
Switch case looping
 
(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_i(6) c sharp introduction_advanced_features_part_i
(6) c sharp introduction_advanced_features_part_i
 
Survelaine murillo ppt
Survelaine murillo pptSurvelaine murillo ppt
Survelaine murillo ppt
 
Control structures pyhton
Control structures  pyhtonControl structures  pyhton
Control structures pyhton
 
Switch case and looping kim
Switch case and looping kimSwitch case and looping kim
Switch case and looping kim
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
JAVASCRIPT PPT [Autosaved].pptx
JAVASCRIPT PPT [Autosaved].pptxJAVASCRIPT PPT [Autosaved].pptx
JAVASCRIPT PPT [Autosaved].pptx
 
Full Stack Online Course in Marathahalli| AchieversIT
Full Stack Online Course in Marathahalli| AchieversITFull Stack Online Course in Marathahalli| AchieversIT
Full Stack Online Course in Marathahalli| AchieversIT
 
Programming in Arduino (Part 2)
Programming in Arduino  (Part 2)Programming in Arduino  (Part 2)
Programming in Arduino (Part 2)
 
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docxCMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
 
C tour Unix
C tour UnixC tour Unix
C tour Unix
 
【Unite 2017 Tokyo】パフォーマンス向上のためのスクリプトのベストプラクティス(note付き)
【Unite 2017 Tokyo】パフォーマンス向上のためのスクリプトのベストプラクティス(note付き)【Unite 2017 Tokyo】パフォーマンス向上のためのスクリプトのベストプラクティス(note付き)
【Unite 2017 Tokyo】パフォーマンス向上のためのスクリプトのベストプラクティス(note付き)
 
presentation_intro_to_python
presentation_intro_to_pythonpresentation_intro_to_python
presentation_intro_to_python
 

Plus de nicky_walters

Plus de nicky_walters (9)

Pseudocode flowcharts
Pseudocode flowchartsPseudocode flowcharts
Pseudocode flowcharts
 
Data types vbnet
Data types vbnetData types vbnet
Data types vbnet
 
Ndu06 typesof language
Ndu06 typesof languageNdu06 typesof language
Ndu06 typesof language
 
Event driventheory
Event driventheoryEvent driventheory
Event driventheory
 
Debugging
DebuggingDebugging
Debugging
 
Input output
Input outputInput output
Input output
 
Decisions
DecisionsDecisions
Decisions
 
Intro to visual studio 2008
Intro to visual studio 2008Intro to visual studio 2008
Intro to visual studio 2008
 
Input output
Input outputInput output
Input output
 

Data structures in VB.NET

  • 1. Data structures in VB.NET 1
  • 2. Processing Once the data has been entered into the program, we need to “do something with it” This is the data processing part Most of what you want to do to it has been done before – many times! There are some standard “structures” that it is useful to know about 2
  • 3. How a program runs Variables have a space reserved in memory (they are declared and initialised) They might be given a value The next lines in the program or part of the program that is running are read and executed one at a time 3
  • 4. Conditional statements We might want a program to make some choices based on the data it receives e.g. If intAge > 17 then….. The full syntax in VB is: If condition Then Line of code to execute End If 4
  • 5. Conditional statements Don‟t forget the End If! It is also possible to add another condition, a kind of „either or‟ choice: If condition Then Line of code to execute Else Another line of code if the above condition is false End If 5
  • 6. Conditional statements Whole banks of If…Then statements can be built up to test for various conditions If there are many, this can get confusing and messy Far better in this case to use the Select Case statement 6
  • 7. Conditional statements Syntax: Select Case variable Case possible value or range Line of code to execute Case another possible value Another line of code End Select 7
  • 8. Loop structures These are used when we want lines of code to be executed many times How many times depends on either various conditions being met or we might want it to run a set number of times There are loops for all occasions and programmers have their favourites! 8
  • 9. Loop structures If we want the loop to run a fixed number of times, we use a For…..Next loop This will use a variable as a counter Syntax: For first value To last value Line of code to execute Next value 9
  • 11. Loop structures If you want the loop to carry on an unspecified number of times until a condition is met, use a Do….While Loop Beware! It is possible to create loops that carry on to infinity Infinite loops aren‟t the end of world – the computer may crash so you might lose some unsaved work Pressing Ctrl + Break sometimes works to stop it 11
  • 12. Loop structures Syntax: Do While value=whatever Line of code to execute Loop Or (my favourite): While value=whatever Line of code execute End While 12
  • 14. Loop structures Loops can also be nested This is where it can get really confusing One loop can search through one set of data But it can be running inside another loop This is useful where data is in a table One loop deals with rows The other deals with columns 14
  • 15. Loop structures When nesting loops, it is important to get the code looking tidy The best way to do this is with indentation The section of code after the first line is tabbed in The last line is tabbed out 15
  • 16. Code Example This is a neat piece of code (of course, I wrote it ) It contains two loops – an inner and an outer Can you try to work out what it does? 16
  • 17. Programming terms In this session we have covered the three ways that programs flow Sequence – running one line after another Selection – using conditional statements Iteration – using loops 17