Old exam questions
- The SendMeteor procedure has several errors and will run but will not work
correctly. The game player will not be interested in playing the game for very long
until those logic errors are corrected. Only after they are all corrected will the
game behave as it is designed to. You can assume that everything outside of the
SendMeteor procedure is correct. All the errors are between Sub SendMeteor() and
its End Sub statement.
- What is the 1st error? Show and/or describe how to correct it.
- What is the 2nd error? Show and/or describe how to correct it.
- What is the 3rd error? Show and/or describe how to correct it.
- Your boss tells you that the imgMeteor.Move MeteorX, MeteorY statement has
got to go because the Visual Basic compiler is broken and no longer recognizes the
Move method. Write the statement or statements to replace the Move statement, so
that the program would still work as intended and move the imgMeteor control to the
new location on frmAnimation.
Sub SendMeteor()
For i = 1 To 200
DoEvents
MeteorX = MeteorX + Speed
MeteorY = MeteorY + Speed
imgMeteor.Move MeteorX, MeteorY
imgMeteor.Refresh
If IsHit(CLng(MeteorX), CLng(MeteorY)) Then
imgBurst.Picture = imgMeteor.Picture
imgMeteor.Refresh
stopTime = Timer + 0.5
theTime = Timer
Do While theTime < stopTime
theTime = Timer
Loop
imgMeteor.Visible = False
Hits = Hits + 1
Exit Sub
End If
Misses = Misses + 1
Next i
End Sub