L5_ProceduresEvents

L5_ProceduresEvents - Control Structures Procedures and...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
Control Structures, Procedures, and Events BIT 3444 G. Alan Wang 09.23.2008
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
elational operators Relational operators Operator Name = Equal to q <> Not equal to > Greater than t h < Less than >= Greater than or equal to <= Less than or equal to Is Is IsNot IsNot Murach’s Visual Basic 2005, C5 © 2006, Mike Murach & Associates, Inc. Slide 2
Background image of page 2
Code that uses relational operators p firstName = "Frank" ' equal to a string literal txtYears.Text = "" ' equal to an empty string iscountPercent = 2.3 ' equal to a numeric literal discountPercent 2.3 equal to a numeric literal isValid = False ' equal to the False value code = productCode ' equal to another variable lastName <> "Jones" ' not equal to a string literal years > 0 ' greater than a numeric literal i < months ' less than a variable subtotal >= 500D ' greater than or equal to a Decimal literal value quantity <= reorderPoint ' less than or equal to a ariable variable message Is Nothing ' equal to a null value address IsNot Nothing ' not equal to a null value Murach’s Visual Basic 2005, C5 © 2006, Mike Murach & Associates, Inc. Slide 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
ogical operators Logical operators Name Description And Returns a True value if both expressions are True. This operator always evaluates both expressions. Or Returns a True value if either expression is True. This operator always evaluates both expressions. AndAlso Returns a True value if both expressions are True. This operator only evaluates the second expression if necessary. OrElse Returns a True value if either expression is True. This operator only evaluates the second expression if necessary. Not Reverses the value of the expression. Murach’s Visual Basic 2005, C5 © 2006, Mike Murach & Associates, Inc. Slide 4
Background image of page 4
AndAlso If (Age >=65) ANDALSO (PensionBalance > 100000) the age is less than 65 there is no point in • If the age is less than 65 there is no point in checking the pension balance. • The condition would not be met. 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
OrElse If (Month=”December”) ORELSE (Month=”January”) • We want to know if it is one of these two onths months. • If the month is December we can proceed ith the rest of the program with the rest of the program. 6
Background image of page 6
ode that uses logical operators Code that uses logical operators isValid = True And counter + 1 < years isValid = False Or counter + 1 >= years subtotal >= 250D AndAlso subtotal < 500D timeInService <= 4 OrElse timeInService >= 12 today > startDate _ d A l td < i t i Dt OE l iVl i d T AndAlso today < expirationDate OrElse isValid = True ((thisYTD > lastYTD) OrElse empType = "Part time") _ AndAlso startYear < currentYear Not (counter + 1 >= years) Murach’s Visual Basic 2005, C5 © 2006, Mike Murach & Associates, Inc. Slide 7
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
The syntax of the If statement If condition Then statements [ ElseIf condition Then statements] . .. [ Else statements] End If Murach’s Visual Basic 2005, C5 © 2006, Mike Murach & Associates, Inc. Slide 8
Background image of page 8
An If statement without an ElseIf or Else clause If subtotal >= 100 Then discountPercent = .2D End If An If statement with an Else clause If subtotal >= 100 Then discountPercent = .2D lse Else discountPercent = .1D End If n If statement with ElseIf clauses An If statement with ElseIf clauses If subtotal >= 100 And subtotal < 200 Then discountPercent = .2D
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 43

L5_ProceduresEvents - Control Structures Procedures and...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online