Making Decisions in VB - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

Making Decisions in VB

Description:

Title: Making Decisions in VB Author: Pat McKeown Last modified by: Dale Goodhue Created Date: 10/8/1996 7:55:46 PM Document presentation format: On-screen Show – PowerPoint PPT presentation

Number of Views:168
Avg rating:3.0/5.0
Slides: 11
Provided by: PatM88
Category:
Tags: decisions | making

less

Transcript and Presenter's Notes

Title: Making Decisions in VB


1
Making Decisions in VB
2
The if-then-else Structure in VB
  • if ltcondition 1gt then
  • statements to execute if condition 1 is true
  • elseif ltcondition 2gt then
  • statements to execute if condition 2 is true
  • else
  • statements to execute if earlier conditions not
    true
  • endif

3
Types of Conditions
  • equality if ThisValue NewValue then
  • inequality if ThisValue ltgt OldValue then
  • greater than if ThisValue gt MyValue then
  • less than if ThisValue lt YourValue then
  • greater than or equal to if Big gt Small then
  • less than or equal to if Big lt Huge then

4
if-then-else Example
  • if BankBalance gt 500 then
  • ServiceCharge 0
  • else
  • ServiceCharge 5
  • endif

5
if-then-elseif-else Example
if BankBalance gt 500 then ServiceCharge
0 elseif BankBalance gt 250 then ServiceCharge
3 else ServiceCharge 5 endif
6
if-then with No else Example
  • if NumCuts gt 5 then
  • stGrade F
  • endif

7
Nested If Statements
  • If stSex M Then
  • If iAge gt 18 Then
  • stCategory Adult Male
  • Elseif iAge gt 12 Then
  • stCategory Teen Male
  • Elseif iAge gt 2 then
  • stCategory PreTeen Male
  • Else stCategory Infant Male
  • Endif
  • Else
  • if iAge gt 18 Then
  • stCategory Adult Female
  • Else stCategory Non Adult Female
  • Endif
  • Endif

8
If2ElseIf Example2 Water Bill
  • if WaterUse lt 1000 then
  • Bill WaterUse.005
  • elseif WaterUse lt 2000 then
  • Bill 5 (WaterUse - 2000).010
  • elseif WaterUse lt 5000 then
  • Bill 15 (WaterUse - 2000).015
  • else
  • Bill 60 (WaterUse - 5000) .025
  • endif

9
Income Taxes for Single Filers Standard Deduction
-- 4000 Dependents -- 2550 each Tax Calculation
on resulting taxable income Taxable Income Amount
Percent Of Amt Over 0-24,000 0 15 0 24,000-
58,150 3,600 28 24,000 58,150-
121,300 13,162 31 58,150 121,300-
262,750 32,738.50 36 121,300 263,750
up 84,020.50 39.6 263.750
10
The Select Case Decision Structure Syntax
Select Case Grade Case Is gt 90
LetterGrade "A" Case Is gt 80
LetterGrade "B" Case Is gt 70
LetterGrade "C" Case Is gt 60
LetterGrade "D" Case Else
LetterGrade "F" End Select
Write a Comment
User Comments (0)
About PowerShow.com