Page 135 - Open Soource Technologies 304.indd
P. 135
Unit 6: VB Control Structure
txtResult.Text = “Break even”
Else
If costs < revenue Then
profit = revenue - costs
txtResult.Text = “Profit is “ & FormatCurrency(profit)
Else
loss = costs - revenue
txtResult.Text = “Loss is “ & FormatCurrency(loss)
End If
End If
End Sub
[Run, type 9500 and 8000 into the text boxes, and press the button.]
3: The If block in the following program has a logical operator in its condition.
Object Property Setting
frmQuiz Text A Quiz
lblQuestion Text How many gallons does a
txtAnswer tengallon hat hold?
btnEvaluate Text Evaluate Answer
txtSolution ReadOnly True
LOVELY PROFESSIONAL UNIVERSITY 129