SlideShare a Scribd company logo
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

More Related Content

PPT
Human Computer Interaction Chapter 5 Universal Design and User Support - Dr....
PPTX
User interface design
PPT
HCI - Chapter 1
PPTX
Socio organizational issues ppt
PPT
HCI 3e - Ch 1: The human
PPT
HCI 3e - Ch 4: Paradigms
PPTX
Diagnostic software tools
PPT
HCI Fundamentals - Part 2 : Human memory and thinking
Human Computer Interaction Chapter 5 Universal Design and User Support - Dr....
User interface design
HCI - Chapter 1
Socio organizational issues ppt
HCI 3e - Ch 1: The human
HCI 3e - Ch 4: Paradigms
Diagnostic software tools
HCI Fundamentals - Part 2 : Human memory and thinking

What's hot (20)

DOCX
Incremental Model
PPTX
File management
PDF
Ch 01-types-and-components-of-computers
PPTX
The different components of a computer system
PPT
HCI 3e - Ch 11: User support
PPT
HCI 3e - Ch 15: Task analysis
PPTX
5 investigating system requirements
PDF
User Interface Design - Module 1 Introduction
PPTX
Unit2 hci
PPT
Operating Systems
ODP
New or obscure web browsers (4x3 draft 5)
 
PPT
HCI - Chapter 3
PPTX
Computer peripheral or Peripheral Devices
PPT
An introduction to microsoft_word
PPTX
Operating system
PPTX
Computer peripheral or Peripheral Devices
PDF
Big data
PDF
Hci activity#2
PDF
Ticket Tagger: Machine Learning Driven Issue Classification
PDF
Introduction to MS Office
Incremental Model
File management
Ch 01-types-and-components-of-computers
The different components of a computer system
HCI 3e - Ch 11: User support
HCI 3e - Ch 15: Task analysis
5 investigating system requirements
User Interface Design - Module 1 Introduction
Unit2 hci
Operating Systems
New or obscure web browsers (4x3 draft 5)
 
HCI - Chapter 3
Computer peripheral or Peripheral Devices
An introduction to microsoft_word
Operating system
Computer peripheral or Peripheral Devices
Big data
Hci activity#2
Ticket Tagger: Machine Learning Driven Issue Classification
Introduction to MS Office
Ad

Viewers also liked (20)

PPTX
Data structure and its types
PPT
DATA STRUCTURES
PPTX
Using loops
PPTX
Data types vbnet
PPTX
Decisions
PPTX
Simple debugging
PPTX
Design for edp
PPTX
Software development lifecycle
PPT
Ch 3 event driven programming
PPTX
Ndu06 typesof language
PPTX
Decisions
PPTX
Design documentation
PPTX
Simple debugging
PPTX
Event driven theory
PPTX
Data types vbnet
PPT
Algorithms
PPTX
Event driven programming amazeballs
PPTX
Controls
DOCX
Event oriented programming
PPT
Event+driven+programming key+features
Data structure and its types
DATA STRUCTURES
Using loops
Data types vbnet
Decisions
Simple debugging
Design for edp
Software development lifecycle
Ch 3 event driven programming
Ndu06 typesof language
Decisions
Design documentation
Simple debugging
Event driven theory
Data types vbnet
Algorithms
Event driven programming amazeballs
Controls
Event oriented programming
Event+driven+programming key+features
Ad

Similar to Data structures vb (20)

PPTX
My final requirement
PPTX
Switch case and looping jam
PPTX
Macasu, gerrell c.
PPTX
Switch case and looping new
PPTX
Yeahhhh the final requirement!!!
PPTX
Looping and switch cases
PPTX
APP_Unit 1_updated.pptx
PPTX
Switch case looping
PDF
(6) c sharp introduction_advanced_features_part_i
PPTX
Survelaine murillo ppt
PPT
Control structures pyhton
PPTX
Switch case and looping kim
PPTX
basics of python - control_structures_and_debugging.pptx
PPTX
Switch case and looping
PPTX
Introduction& Overview-to-C++_programming.pptx
PPTX
Introduction to C++ programming language
PPTX
Full Stack Online Course in Marathahalli| AchieversIT
PPTX
JAVASCRIPT PPT [Autosaved].pptx
PPS
Programming in Arduino (Part 2)
DOCX
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx
My final requirement
Switch case and looping jam
Macasu, gerrell c.
Switch case and looping new
Yeahhhh the final requirement!!!
Looping and switch cases
APP_Unit 1_updated.pptx
Switch case looping
(6) c sharp introduction_advanced_features_part_i
Survelaine murillo ppt
Control structures pyhton
Switch case and looping kim
basics of python - control_structures_and_debugging.pptx
Switch case and looping
Introduction& Overview-to-C++_programming.pptx
Introduction to C++ programming language
Full Stack Online Course in Marathahalli| AchieversIT
JAVASCRIPT PPT [Autosaved].pptx
Programming in Arduino (Part 2)
CMIS 102 Hands-On Lab Week 4OverviewThis hands-on lab all.docx

More from nicky_walters (9)

PPTX
Pseudocode flowcharts
PPTX
Data types vbnet
PPTX
Ndu06 typesof language
PPTX
Event driventheory
PPTX
Debugging
PPTX
Input output
PPTX
Decisions
PPTX
Intro to visual studio 2008
PPTX
Input output
Pseudocode flowcharts
Data types vbnet
Ndu06 typesof language
Event driventheory
Debugging
Input output
Decisions
Intro to visual studio 2008
Input output

Data structures vb

  • 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