CSE 100: Lab, April 13


We'll be looking at a sample application while we discuss the first couple topics. Create a new folder on your floppy disk and download the following files there to follow along:


variables: storing data

Think of it like the Memory button on your calculator.

vocabulary

types: What kind of data do you want to store?

So far, we've seen two:

A new one, similar to Integer...

declaration syntax

You can place declarations inside or outside procedures. More on this in a second when we talk about scope.

Dim variable_name As type

Dim name_1 As type_1, name_2 As type_2, .., name_n As type_n

assignment syntax

Assignments can only be in procedures (Subs and Functions).

variable_name = expression

scope: the variable's "neighborhood"

The scope of a variable is the section or sections of code where it can be useda, i.e. assigned and read.

global vs. local

The key is where the variable is declared.

Unless you really need a variable in more than one procedure, it's a good idea to stick with locals.


procedures (Subs): Do one job and do it well.

vocabulary

What's a procedure, really?

Why do we use them?

definition syntax

Sub procedure_name(formal_parameter As type, ..)
    statement
    ..
End Sub

call syntax

Call procedure_name(actual_parameter, ..)
Make sure: right number of parameters, right order.

Note correspondence between formal and actual parameters.


exercise

Remember the basic stages of a developing a Visual Basic application:

  1. assemble a user interface---what the window should look like
  2. add code to tie the controls together
We'll set up the controls and write a little bit of code together, but you'll finish it off yourself.

The key is recognizing that it'd be a good idea to design your program to include a procedure or two. Before we start developing, we'll discuss this. It's always a good idea to have a solid plan before you do any work on the computer.

sample program

See how your program should work when you're done by downloading the sample program to the Desktop and running it a few times:

starter project and form files

To save you some time and let us work on the more interesting parts of this program, we're providing form and project files for you to start with. Download them into a new folder on your floppy disk:"

Note that almost all of the user interface is already done, with the exception of one radio (option) button (the one for size grande). Some of the code has been written, too, including event handlers for one of the radio buttons and a small subroutine for adding sales tax. We'll talk more about what you need to add to complete this program.

pricing guidelines

The price of a latte depends on its size (short, tall, or grande) and number of espresso shots:











Ken Yasuhara <yasuhara@cs.washington.edu>
Last modified: Thu Apr 15 10:13:19 PDT 1999