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

C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointJavaTpoint.Com
 
4 evolution-of-programming-languages
4 evolution-of-programming-languages4 evolution-of-programming-languages
4 evolution-of-programming-languagesRohit Shrivastava
 
Algorithm and pseudo codes
Algorithm and pseudo codesAlgorithm and pseudo codes
Algorithm and pseudo codeshermiraguilar
 
Dijkstra & flooding ppt(Routing algorithm)
Dijkstra & flooding ppt(Routing algorithm)Dijkstra & flooding ppt(Routing algorithm)
Dijkstra & flooding ppt(Routing algorithm)Anshul gour
 
Lec 02 logical eq (Discrete Mathematics)
Lec 02   logical eq (Discrete Mathematics)Lec 02   logical eq (Discrete Mathematics)
Lec 02 logical eq (Discrete Mathematics)Naosher Md. Zakariyar
 
R Programming: Mathematical Functions In R
R Programming: Mathematical Functions In RR Programming: Mathematical Functions In R
R Programming: Mathematical Functions In RRsquared Academy
 
Program design techniques
Program design techniquesProgram design techniques
Program design techniquesfika sweety
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithmsDr Geetha Mohan
 
Predicate Logic
Predicate LogicPredicate Logic
Predicate Logicgiki67
 
Compiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRCompiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRRiazul Islam
 
Intro automata theory
Intro automata theory Intro automata theory
Intro automata theory Rajendran
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Aman Sharma
 
Declarative programming language
Declarative programming languageDeclarative programming language
Declarative programming languageVinisha Pathak
 

Tendances (20)

C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
 
4 evolution-of-programming-languages
4 evolution-of-programming-languages4 evolution-of-programming-languages
4 evolution-of-programming-languages
 
Algorithm and pseudo codes
Algorithm and pseudo codesAlgorithm and pseudo codes
Algorithm and pseudo codes
 
Relational model
Relational modelRelational model
Relational model
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 
Dijkstra & flooding ppt(Routing algorithm)
Dijkstra & flooding ppt(Routing algorithm)Dijkstra & flooding ppt(Routing algorithm)
Dijkstra & flooding ppt(Routing algorithm)
 
Control statements
Control statementsControl statements
Control statements
 
Lec 02 logical eq (Discrete Mathematics)
Lec 02   logical eq (Discrete Mathematics)Lec 02   logical eq (Discrete Mathematics)
Lec 02 logical eq (Discrete Mathematics)
 
Java assignment Question
Java assignment QuestionJava assignment Question
Java assignment Question
 
R Programming: Mathematical Functions In R
R Programming: Mathematical Functions In RR Programming: Mathematical Functions In R
R Programming: Mathematical Functions In R
 
Program design techniques
Program design techniquesProgram design techniques
Program design techniques
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
 
CLR AND LALR PARSER
CLR AND LALR PARSERCLR AND LALR PARSER
CLR AND LALR PARSER
 
Predicate Logic
Predicate LogicPredicate Logic
Predicate Logic
 
Dbms normalization
Dbms normalizationDbms normalization
Dbms normalization
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
 
Compiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRCompiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLR
 
Intro automata theory
Intro automata theory Intro automata theory
Intro automata theory
 
Lexical Analysis - Compiler design
Lexical Analysis - Compiler design Lexical Analysis - Compiler design
Lexical Analysis - Compiler design
 
Declarative programming language
Declarative programming languageDeclarative programming language
Declarative programming language
 

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