Monday, September 13, 2010

notes for lecture #3

1) Draw your GUI
2) Write your code

A bug
A syntax error causes build errors
A logic error
Runtime errors


Hello world program
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label1.Text = "Hello, world!"
    End Sub
End Class

Plato perfect age
Option Explicit On
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim manAge As Integer
        Dim wifeAge As Integer

        ' Get input
        manAge = TextBox1.Text

        ' Processing
        wifeAge = manAge / 2 + 7

        ' Display output
        Label3.Text = wifeAge
    End Sub
End Class

I'm naming controls (though not other variables) using "Hungarian"

camelCase

Apply a 10 point curve
Option Explicit On
Public Class Form1

    Private Sub btnCalculateCurve_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculateCurve.Click
        Dim grade As Integer
        Dim curvedGrade As Integer

        ' Get input
        grade = txtGrade.Text

        ' Processing
        curvedGrade = grade + 10

        ' Display output
        lblCurvedGrade.Text = curvedGrade
    End Sub
End Class

No comments:

Post a Comment