L5_ProceduresEvents

# L5_ProceduresEvents - Control Structures Procedures and...

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

Control Structures, Procedures, and Events BIT 3444 G. Alan Wang 09.23.2008

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

View Full Document
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
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

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

View Full Document
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
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

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

View Full Document
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
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

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

View Full Document
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
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

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

View Full Document
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
Ask a homework question - tutors are online