Page 124 - Open Soource Technologies 304.indd
P. 124
Event Driven Programming
In the first example, MyFunction() is called, even though 12 > 45 returns False, because And does
not short circuit. In the second example, MyFunction is not called, because 12 > 45 returns False,
so AndAlso short circuits the second expression. In the third example, MyFunction is called, even
though 45 > 12 returns True, because Or does not short circuit. In the fourth example, MyFunction
is not called because 45 > 12 returns True, so OrElse short circuits the second expression
Consider the following program that displays the address of the Delhi House. (The form
design for all examples in this section consists of a button and a text or list box.)
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim houseNumber As Double
Dim street, address As String
houseNumber = 1600
street = “Pennsylvania Ave.”
address = houseNumber & “ “ & street
txtAddr.Text = “The Delhi House is located at “ & address
End Sub
[Run, and then click the button. The following is displayed in the text box.]
The Delhi House is located at Safadarjung.
Questions
1. Compare the three number using operators.
2. How to convert string into integers?
5.5 Summary
• String are the most common type of data processed by visual basic.
• Math operators are addition and subtraction.
• Visual basic evaluates the expression in parentheses from left to right, using pairs of
operands and their associated operator.
• The logical operators compare boolean expressions and return a boolean result.
5.6 Keywords
Concatenation operators: Join multiple strings in to a single string. They are two operators,
t and f.
Exponents: They are known as powers of a number. They are used is many things which are
represented as power of two.
118 LOVELY PROFESSIONAL UNIVERSITY