- Insert the new controls
Add a new command button and set its name to cmdFly and its caption to Fly. If you have a look at the printout, you should be able to see the description of this command button on the second page. It should look something like
Begin VB.CommandButton cmdFly
Caption = "Fly"
....
- Copy globals
Go to the code editor. Use the object list and event list (see Exercise 3)to change to the general declarations section.
Copy the following code (which is at the top of the printout) into the code editor
'Global variables
Dim flying As Boolean
- Copy the code for "click fly button" event
Go to the code editor, set the object list to cmdFly and the event list to Click. Now insert the following code, which can be found on page one of the printout, into this procedure.
If flying Then
flying = False
cmdFly.Caption = "Fly"
Else
flying = True
cmdFly.Caption = "Stop"
End If
- Copy the code for the mouse movement over the form background
In the code editor, set the object list to Form (or whatever you named your calculate button) and your event list to MouseMove
Now copy the following code for this procedure (which is on the first page of the printout)
If flying Then
frmRoomCalc.Top = frmRoomCalc.Top + 10
frmRoomCalc.Left = frmRoomCalc.Left + 10
End If
- You should be done now, so run your project to test it out.