Lab 1.2 – Writing to a File

 

Goals:

    w Continue study of 112 textbook

    w Output data produced to a file

 

Outline:

    w Read the first 10 pages of Chapter 3

    w Do 112 lab 2.0.

    w Write some more code moving toward Proj. #1

 

__1. Read the first 10 pages of Chapter Three of the 112 textbook.  Answer these questions.

          w What is an expression?

          w What is Option Explicit?  Why should you use it?

          w Can identifiers have dashes in them?

          w Give two examples of “named storage locations”.

          w What are the 4 basic internal operations of a computer?

          w Give the general form of the assignment statement.

          w List all the unary arithmetic operators.

          w What is the difference between an operator and an operand?

          w In VB what are the bounded units of execution?  What is the main

             difference between them?

 

__2. Do 112 lab 2.0.  Answer these questions.

          w What is a Boolean expression?

          w How is the visible property related to the Hide and Show methods?

          w How many methods operate on the textbox control?

          w Last fall Barry Bonds set a new home run record.  Change the

             program to reflect that.

 

__3. Write a program to write data to a file.

          w Begin a new VB project.

          w Place one command button on the form, giving it the code below:

                        Dim i, pow2i As Long

                          Open App.Path & "\powers" For Output As #1

                          For i = 1 To 30

                             pow2i = 2 ^ i

                             Print #1, i, pow2i

                          Next i

          w Run the program.

          w After exiting the program, open the file powers using Wordpad or

             Notepad.  What do you see?

          w Study the code.  What do you think is the purpose of App.Path?

          w Change the 30 in the first line of the For loop to 31.  Run the

              program.  What happens?  Why?

          w Can you think of a way to eliminate one of the local variables and

              also shorten the code by one line?  How?