CSC301 - Chapter 3
CSC301 - Chapter 3
COMPARISON
OPERATORS (1 OF 2)
Comparison or
relational operators are
used to compare two
values.
Expressions containing a
comparison operator
always evaluate to a
Boolean value: either
True or False.
COMPARISON Evaluation steps for expressions containing arithmetic and
OPERATORS (2 OF 2) comparison operators.
Comparison operators in
Visual Basic do not have an
order of precedence.
When an expression contains
more than one comparison
operator, the computer
evaluates the comparison
operators from left to right in
the expression.
However, comparison
operators are evaluated after
any arithmetic operators as in
examples shown.
OPERATOR OPERATIONS PRECEDENCE
LOGICAL NUMBER
OPERATORS (1 OF 3) Not Reverses the truth-value of the condition;True becomes 1
False, and False becomes True
When more than one
And All subconditions must be true for the compound 2
condition is included in an condition to evaluate to True
If...Then...Else statement,
AndAlso As soon as a condition is found to be false, no further 2
the conditions are called a
conditions are tested and the compound condition is false
compound condition.
Logical operator allows Or Only one of the subconditions needs to be true for the 3
you to combine two or compound condition to evaluate to True
more conditions into a
OrElse As soon as a condition is found to be true, no further 3
compound condition that conditions are tested and the compound condition is true
can be tested with an If
statement.
Xor One and only one of the subconditions can be true for the 4
compound condition to evaluate to True
LOGICAL
OPERATORS (2 OF 3)
STRING
COMPARISONS
(2 OF 3)
STRING
COMPARISONS
(3 OF 3)
Message Box
Radio Buttons
Check Boxes
DISPLAY A MESSAGE
BOX (1 OF 5)
General format to
display message box
statement.
A message box can be displayed during
execution with a variety of arguments.
In many applications, the caption is used to
give further information to the user.
DISPLAY A
MESSAGE
BOX (3 OF 5)
DISPLAY A MESSAGE BOX (4 OF 5)
MsgBoxButtons Arguments Value Use
MsgBoxStyle.OKOnly 0 Displays an OK button —
default setting
MsgBoxStyle.OKCancel 1 Displays an OK and
Cancel button
MsgBoxStyle.AbortRetryIgnore 2 After a failing situation,
the user can choose to
Abort, Retry, or Ignore
MsgBoxStyle.YesNoCancel 3 Displays Yes, No, and
Cancel buttons
MsgBoxStyle.YesNo 4 Displays Yes and No
buttons
MsgBoxStyle.RetryCancel 5 After an error occurs, the
user can choose to Retry
or Cancel
DISPLAY A
MESSAGE BOX (5
OF 5)
To create the message in the message box,
you can use concatenation.
STRING
CONCATENATION
RADIO
BUTTONS (2
OF 2) In the following example code, assume that radCoffee, radTea,
and radSoftDrink are radio buttons within the same group.
A check box provides an option that the user can
either choose to select or choose not to select.
The option offered by each check box must be
unique and unrelated to any of the other check
box options.
Commonly used properties of a check box as shown
CHECK BOX below.
(1 OF 3)
The following code demonstrates
CHECK BOX (2 OF 3) check boxes.
END OF CHAPTER 3