SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Review of the Basics Advanced Visual Basic
Overview You are now in at least your third semester of programming.  In this course, we will be exploring more of Visual Basic.  Before doing so, we should re-familiarize ourselves with the development environment and some of the basic programming topics.
Variables You often have to store values when you perform calculations with Visual Basic. For example, you might want to calculate several values, compare them, and perform different operations on them, depending on the result of the comparison. You have to retain the values if you want to compare them.Variables store values in RAM. A variable has a name (the word that you use to refer to the value that the variable contains). A variable also has a data type (which determines the kind of data that the variable can store). Example: Dim strFirstName As String
Variables Research Question:  What is the difference between a variable and a constant?
Arrays An array is a set of values that are logically related to each other, such as the number of students in each grade in a grammar school. An array allows you to refer to these related values by the same name and to use a number, called an index or subscript, to tell them apart. The individual values are called the elements of the array. They are contiguous from index 0 through the highest index value. Example: Dim strStudentNames(10) As String
Arrays Research Question:  How many elements are in this array? Dim strStudentNames(10) As String
Loops Visual Basic loop structures allow you to run one or more lines of code repetitively. You can repeat the statements in a loop structure until a condition is True, until a condition is False, a specified number of times, or once for each element in a collection.
Loops (while) Use a While...End While structure when you want to repeat a set of statements an indefinite number of times, as long as a condition remains True. Example: Dim counter As Integer = 0  While counter < 3  counter += 1  ‘Insert code to use current value of counter.  End While  MsgBox("While loop ran " & CStr(counter) & " times")
Loops (do) Use a Do...Loop structure when you want to repeat a set of statements an indefinite number of times, until a condition is satisfied. Example: Dim counter As Integer = 0  Dim number As Integer = 10 Do Until number = 100  	number = number * 10  counter += 1  Loop  MsgBox("The loop ran " & counter & " times.")
Loops (for…next) Use a For...Next structure when you want to repeat a set of statements a set number of times. Example: For index As Integer = 1 To 5 Debug.Write(index.ToString & " ")  Next  Debug.WriteLine("") ' Output: 1 2 3 4 5
Loops (for each) Use a For Each...Next loop when you want to repeat a set of statements for each element of a collection or array. Example: Sub BlueBackground(ByValthisFormAs System.Windows.Forms.Form) For Each thisControl As System.Windows.Forms.ControlIn thisForm.Controls thisControl.BackColor= System.Drawing.Color.LightBlue Next thisControl End Sub
Loops Research Question:  What happens when a loop doesn’t end? 			Dim intValue as integer = 1 			Do Until intValue = 2 MessageBox.Show(“you have a problem!”) 			Loop
Decisions Visual Basic lets you test conditions and perform different operations depending on the results of that test. You can test for a condition being true or false, for various values of an expression, or for various exceptions generated when you execute a series of statements.
Decisions (if…then…else) When an If...Then...Else statement is encountered, condition is tested. If condition is True, the statements following Then are executed. If condition is False, each ElseIf statement (if there are any) is evaluated in order. When a True elseifcondition is found, the statements immediately following the associated ElseIf are executed. If no elseifcondition evaluates to True, or if there are no ElseIf statements, the statements following Else are executed. After executing the statements following Then, ElseIf, or Else, execution continues with the statement following End If. Example: Dim count As Integer = 0  Dim message As String  If count = 0 Then  message = "There are no items."  ElseIfcount = 1 Then  message = "There is 1 item."  Else  message = "There are " & count & " items."  End If
Decisions (if…then…else) The Case Else statement is used to introduce the elsestatements to run if no match is found between the testexpression and an expressionlist clause in any of the other Case statements. Although not required, it is a good idea to have a Case Else statement in your Select Case construction to handle unforeseen testexpression values Example: Dim number As Integer = 8  Select Case number  Case 1 To 5  Debug.WriteLine("Between 1 and 5, inclusive") Case 6, 7, 8  Debug.WriteLine("Between 6 and 8, inclusive")  Case 9 To 10  Debug.WriteLine("Equal to 9 or 10")  Case Else  Debug.WriteLine("Not between 1 and 10, inclusive")  End Select
Decisions Research Question:  What is the most efficient way to determine if someone can vote? Consider:  Age = 17 Age = 18 Age = 19
Additional Information For additional information about these topics, please review your text and the links provided in Blackboard.

Weitere ähnliche Inhalte

Was ist angesagt?

Cpu-fundamental of C
Cpu-fundamental of CCpu-fundamental of C
Cpu-fundamental of C
Suchit Patel
 
Operators , Functions and Options in VB.NET
Operators , Functions and Options in VB.NETOperators , Functions and Options in VB.NET
Operators , Functions and Options in VB.NET
Shyam Sir
 

Was ist angesagt? (19)

Ppt lesson 08
Ppt lesson 08Ppt lesson 08
Ppt lesson 08
 
Ch03
Ch03Ch03
Ch03
 
Ppt lesson 07
Ppt lesson 07Ppt lesson 07
Ppt lesson 07
 
10 array
10 array10 array
10 array
 
Structures in c language
Structures in c languageStructures in c language
Structures in c language
 
[ITP - Lecture 04] Variables and Constants in C/C++
[ITP - Lecture 04] Variables and Constants in C/C++[ITP - Lecture 04] Variables and Constants in C/C++
[ITP - Lecture 04] Variables and Constants in C/C++
 
Cpu-fundamental of C
Cpu-fundamental of CCpu-fundamental of C
Cpu-fundamental of C
 
Ch02
Ch02Ch02
Ch02
 
Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2
 
Pseudocode
PseudocodePseudocode
Pseudocode
 
StandardsandStylesCProgramming
StandardsandStylesCProgrammingStandardsandStylesCProgramming
StandardsandStylesCProgramming
 
Introduction To Programming
Introduction To ProgrammingIntroduction To Programming
Introduction To Programming
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointers
 
Operators , Functions and Options in VB.NET
Operators , Functions and Options in VB.NETOperators , Functions and Options in VB.NET
Operators , Functions and Options in VB.NET
 
Enumerated data types
Enumerated data typesEnumerated data types
Enumerated data types
 
Enums in c
Enums in cEnums in c
Enums in c
 
Ch06
Ch06Ch06
Ch06
 
enums
enumsenums
enums
 

Ähnlich wie Advanced VB: Review of the basics

Vb6 ch.8-3 cci
Vb6 ch.8-3 cciVb6 ch.8-3 cci
Vb6 ch.8-3 cci
Fahim Khan
 
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
monicafrancis71118
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
ch samaram
 
Chapter2pp
Chapter2ppChapter2pp
Chapter2pp
J. C.
 

Ähnlich wie Advanced VB: Review of the basics (20)

VISUAL BASIC 6 - CONTROLS AND DECLARATIONS
VISUAL BASIC 6 - CONTROLS AND DECLARATIONSVISUAL BASIC 6 - CONTROLS AND DECLARATIONS
VISUAL BASIC 6 - CONTROLS AND DECLARATIONS
 
vb.net.pdf
vb.net.pdfvb.net.pdf
vb.net.pdf
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
 
Vb script tutorial
Vb script tutorialVb script tutorial
Vb script tutorial
 
Sharbani bhattacharya VB Structures
Sharbani bhattacharya VB StructuresSharbani bhattacharya VB Structures
Sharbani bhattacharya VB Structures
 
Software fundamentals
Software fundamentalsSoftware fundamentals
Software fundamentals
 
Vb6 ch.8-3 cci
Vb6 ch.8-3 cciVb6 ch.8-3 cci
Vb6 ch.8-3 cci
 
VB(unit1).pptx
VB(unit1).pptxVB(unit1).pptx
VB(unit1).pptx
 
Java Basics 1.pptx
Java Basics 1.pptxJava Basics 1.pptx
Java Basics 1.pptx
 
M C6java2
M C6java2M C6java2
M C6java2
 
The Swift Programming Language - Xcode6 for iOS App Development - AgileInfowa...
The Swift Programming Language - Xcode6 for iOS App Development - AgileInfowa...The Swift Programming Language - Xcode6 for iOS App Development - AgileInfowa...
The Swift Programming Language - Xcode6 for iOS App Development - AgileInfowa...
 
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
 
The swift programming language
The swift programming languageThe swift programming language
The swift programming language
 
Data Structures- Part1 overview and review
Data Structures- Part1 overview and reviewData Structures- Part1 overview and review
Data Structures- Part1 overview and review
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Perl slid
Perl slidPerl slid
Perl slid
 
Chapter2pp
Chapter2ppChapter2pp
Chapter2pp
 
Ruby Basics
Ruby BasicsRuby Basics
Ruby Basics
 
pythonQuick.pdf
pythonQuick.pdfpythonQuick.pdf
pythonQuick.pdf
 

Mehr von robertbenard (20)

Sample
SampleSample
Sample
 
Xampe
XampeXampe
Xampe
 
Accessing data within VB Applications
Accessing data within VB ApplicationsAccessing data within VB Applications
Accessing data within VB Applications
 
Advanced VB: Object Oriented Programming - Controls
Advanced VB: Object Oriented Programming - ControlsAdvanced VB: Object Oriented Programming - Controls
Advanced VB: Object Oriented Programming - Controls
 
Advanced VB: Object Oriented Programming - DLLs
Advanced VB: Object Oriented Programming - DLLsAdvanced VB: Object Oriented Programming - DLLs
Advanced VB: Object Oriented Programming - DLLs
 
Advanced VB: Review of the basics
Advanced VB: Review of the basicsAdvanced VB: Review of the basics
Advanced VB: Review of the basics
 
Copyright Basics
Copyright BasicsCopyright Basics
Copyright Basics
 
Cascading Style Sheets in Dreamweaver
Cascading Style Sheets in DreamweaverCascading Style Sheets in Dreamweaver
Cascading Style Sheets in Dreamweaver
 
Performance Assessment Task
Performance Assessment TaskPerformance Assessment Task
Performance Assessment Task
 
WIDS Jeopardy
WIDS JeopardyWIDS Jeopardy
WIDS Jeopardy
 
Wids Model
Wids ModelWids Model
Wids Model
 
Lesson 2
Lesson 2Lesson 2
Lesson 2
 
Lists, formatting, and images
Lists, formatting, and imagesLists, formatting, and images
Lists, formatting, and images
 
Lesson 7
Lesson 7Lesson 7
Lesson 7
 
Lesson 6
Lesson 6Lesson 6
Lesson 6
 
Lesson 5
Lesson 5Lesson 5
Lesson 5
 
Lesson 4
Lesson 4Lesson 4
Lesson 4
 
Lesson 3
Lesson 3Lesson 3
Lesson 3
 
Lesson 1
Lesson 1Lesson 1
Lesson 1
 
Lesson 1
Lesson 1Lesson 1
Lesson 1
 

Kürzlich hochgeladen

Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 

Kürzlich hochgeladen (20)

Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 

Advanced VB: Review of the basics

  • 1. Review of the Basics Advanced Visual Basic
  • 2. Overview You are now in at least your third semester of programming. In this course, we will be exploring more of Visual Basic. Before doing so, we should re-familiarize ourselves with the development environment and some of the basic programming topics.
  • 3. Variables You often have to store values when you perform calculations with Visual Basic. For example, you might want to calculate several values, compare them, and perform different operations on them, depending on the result of the comparison. You have to retain the values if you want to compare them.Variables store values in RAM. A variable has a name (the word that you use to refer to the value that the variable contains). A variable also has a data type (which determines the kind of data that the variable can store). Example: Dim strFirstName As String
  • 4. Variables Research Question: What is the difference between a variable and a constant?
  • 5. Arrays An array is a set of values that are logically related to each other, such as the number of students in each grade in a grammar school. An array allows you to refer to these related values by the same name and to use a number, called an index or subscript, to tell them apart. The individual values are called the elements of the array. They are contiguous from index 0 through the highest index value. Example: Dim strStudentNames(10) As String
  • 6. Arrays Research Question: How many elements are in this array? Dim strStudentNames(10) As String
  • 7. Loops Visual Basic loop structures allow you to run one or more lines of code repetitively. You can repeat the statements in a loop structure until a condition is True, until a condition is False, a specified number of times, or once for each element in a collection.
  • 8. Loops (while) Use a While...End While structure when you want to repeat a set of statements an indefinite number of times, as long as a condition remains True. Example: Dim counter As Integer = 0 While counter < 3 counter += 1 ‘Insert code to use current value of counter. End While MsgBox("While loop ran " & CStr(counter) & " times")
  • 9. Loops (do) Use a Do...Loop structure when you want to repeat a set of statements an indefinite number of times, until a condition is satisfied. Example: Dim counter As Integer = 0 Dim number As Integer = 10 Do Until number = 100 number = number * 10 counter += 1 Loop MsgBox("The loop ran " & counter & " times.")
  • 10. Loops (for…next) Use a For...Next structure when you want to repeat a set of statements a set number of times. Example: For index As Integer = 1 To 5 Debug.Write(index.ToString & " ") Next Debug.WriteLine("") ' Output: 1 2 3 4 5
  • 11. Loops (for each) Use a For Each...Next loop when you want to repeat a set of statements for each element of a collection or array. Example: Sub BlueBackground(ByValthisFormAs System.Windows.Forms.Form) For Each thisControl As System.Windows.Forms.ControlIn thisForm.Controls thisControl.BackColor= System.Drawing.Color.LightBlue Next thisControl End Sub
  • 12. Loops Research Question: What happens when a loop doesn’t end? Dim intValue as integer = 1 Do Until intValue = 2 MessageBox.Show(“you have a problem!”) Loop
  • 13. Decisions Visual Basic lets you test conditions and perform different operations depending on the results of that test. You can test for a condition being true or false, for various values of an expression, or for various exceptions generated when you execute a series of statements.
  • 14. Decisions (if…then…else) When an If...Then...Else statement is encountered, condition is tested. If condition is True, the statements following Then are executed. If condition is False, each ElseIf statement (if there are any) is evaluated in order. When a True elseifcondition is found, the statements immediately following the associated ElseIf are executed. If no elseifcondition evaluates to True, or if there are no ElseIf statements, the statements following Else are executed. After executing the statements following Then, ElseIf, or Else, execution continues with the statement following End If. Example: Dim count As Integer = 0 Dim message As String If count = 0 Then message = "There are no items." ElseIfcount = 1 Then message = "There is 1 item." Else message = "There are " & count & " items." End If
  • 15. Decisions (if…then…else) The Case Else statement is used to introduce the elsestatements to run if no match is found between the testexpression and an expressionlist clause in any of the other Case statements. Although not required, it is a good idea to have a Case Else statement in your Select Case construction to handle unforeseen testexpression values Example: Dim number As Integer = 8 Select Case number Case 1 To 5 Debug.WriteLine("Between 1 and 5, inclusive") Case 6, 7, 8 Debug.WriteLine("Between 6 and 8, inclusive") Case 9 To 10 Debug.WriteLine("Equal to 9 or 10") Case Else Debug.WriteLine("Not between 1 and 10, inclusive") End Select
  • 16. Decisions Research Question: What is the most efficient way to determine if someone can vote? Consider: Age = 17 Age = 18 Age = 19
  • 17. Additional Information For additional information about these topics, please review your text and the links provided in Blackboard.