Wednesday, October 20, 2010

lecture notes

Midterm: November 3rd
Chapter 1-3; Chapter 5 (meaning decision making)

ElseIf will let us accomplish three-way (or more) branching

Private Sub btnShow_Click(...) Handles btnShow.Click
  Dim costs, revenue, profit, loss As Double
  costs = CDbl (txtCosts.Text)
  revenue = CDbl (txtRev.Text)
  If costs = revenue Then
    txtResult.Text = "Break even"
  ElseIf 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 Sub

10 gallon hat
we used And for intersection, Or for union

Chr(65) = "A"
Asc("A") = 65

Dim code As Integer
code = Asc(TextBox1.text)
If code < Asc("A") Or code > Asc("Z") Then
    txtOutput.Text = "not a capital letter"
Else
    txtOutput.Text = "a capital letter"
EndIf


Magic numbers
Asc("A") instead of 65
self-documenting

HW:
If Blocks
28-44, even


Assignment 6 is due this coming Monday

No comments:

Post a Comment