Be bossy—IT should serve you, not the other way around.
In this lab exercise, we'll look at computer software. The combination of hardware and software is what makes the computer a universal machine—so versatile that it can compute anything we can write code for. Programming is a large and significant topic, so we'll focus just on the fundamentals.
We suggest that you work in pairs (in lock-step), and, if you have any problems with anything, ask one of the other teams or one of us for pointers.
This lab requires that special software ("Peedy the Parrot") be installed on your computer. Thus, you should plan to do this one in SB 372 (our lab).
In this section we'll explore the concept of programming using Peedy, a simple Microsoft agent. Our Peedy application is written in Visual Basic for Applications (VBA) and runs within Microsoft Excel.
To work with Peedy, do the following:
F:drive in your FIT folder, and double-click on it to fire Peedy up.
Take some time to experiment with Peedy.
If you wear your system's headphones, you should hear Peedy "say" things to you. When you're finished, be sure to press Peedy's "stop" button before going on.
The Peedy agent is controlled by a program written in Visual Basic for
Applications (VBA), which you can see by starting up Microsoft's VBA editor.
Do this now by pressing
Alt+F11. You should see the Microsoft
Visual Basic programming environment. You can view the Peedy system using
either of the following two views (the GUI view on the left or the VBA code
view on the right):
Follow the instructions given in the image to view the VBA code that
SpeakIT function. Now, look through the SpeakIT
code (not the whole code file, just this small part of it) and find the
Now we'll use some simple programming to get Peedy to count to 10 on command. We could get Peedy to do this with the following set sequence of commands:
Peedy.Speak "one" Peedy.Speak "two" Peedy.Speak "three" and so forth...
This would be tedious to program, and not very general. Instead, delete
the VBA commands between the appropriate comments (i.e.,
code below here and
Enter in Code above here) and then
add the following code:
Speech = txtSpeak.Text Peedy.Speak Speech If Speech = "count to 10" Then For i = 1 to 10 Peedy.Speak Cstr(i) Next i End If
Cstr function converts the number
1) into the string for
i (i.e., "1"). This code uses
all 3 basic control constructs: If the user tells Peedy to count to
10, then repeatedly say the numbers from 1 to 10. And this is done after Peedy speaks the actual input.
You can run the Peedy GUI with your new code by choosing "Run"-"Run Sub/User Form". This compiles the code you wrote and runs it.
Try this command out now by typing "count to 10" in the Text field and pressing "SpeakIT". (Typing "count to ten" won't work. Why not? Or... if it does, why?)
Now, see if you can add similar code to respond to the command "count to 5" as well. (Hint: do not copy all of the code above, only enough to handle "count to 5".) When you're done, Peedy should be able to count to five or ten, depending on which command is entered.
Feel free to play with Peedy if there is time. Peedy is a simple, cute example of the fundamental technology that drives IT. What we've done here may be limited, but it's an illustration of the power afforded to those that learn how to program computers.
If you have extra time and would like to set some extra credit for this lab, try to solve either of the following challenges (without affecting any of Peedy's previous abilities):
stepclause in your
Peedy.MoveTo x-coordinate, y-coordinatecommand.
For this lab, use KV to submit your modified version of the
lab2-peedy.xlsm file. If necessary, see Lab #1 for instructions
on how to do this.