Lab 5
comp 125-609, Goldwasser
Tuesday, September 28, 1999

Purpose: Using control arrays.

We are going to make a very rudimentary typewriter, where the user clicks on pictures of keys to type.

At design time, your form should have the following three controls, a command button named key, another command button named clear, and a picture box named display. The initial properties should be set as follows:
Object Property Setting
Form1Width7500
Form1Height2025
keyCaptionA
keyHeight375
keyWidth255
keyTop120
keyLeft240
keyIndex0
clearHeight255
clearWidth975
clearTop600
clearLeft240
displayHeight495
displayWidth6855
displayTop960
displayLeft240
displayFontCourierNew


The rest of the program will be in designing the event handlers. You should do three things:
  • In the Form1_Load procedure, we want you to create a control array of 27 keys consisting of the 26 letters followed by a key for inserting a space. key(0) was already created during the design stage. We must loop i from 1 to 26 to create the remaining keys. For each key, do the following:
  • Load key(i)
  • change the value of key(i).Left so that it lies immediately next to the previous key
  • set the value of key(i).Caption to match the correct character
  • set key(i).Visible = True

  • Note that you can get the correct capital letters by setting the caption to equal Chr(Asc("A")+i). You will have to handle the space key as a special case.
  • Make the clear_Click procedure clear the display
  • Make the key_Click procedure display the correct character

  • This lab is due before leaving class today. When you have completed the program you should do the following:
  • (1) Please call me over to your computer to run your program