' Game Program Demo #2
' Mr. Minich
' This program illustrates the use of Picture controls, the App.Path property, Beep,
' variables with the Date data type, and the use of the system time (Time function).
Option Explicit
Dim mStartTime As Date ' the system time at the beginning of the game
Private Sub Form_Load()
mStartTime = Time ' begin timing the user
tmrMoving.Interval = 500 ' butterfly moves every 1/2 second
pctObject.Picture = LoadPicture(App.Path & "\freebutterfly.bmp")
End Sub
Private Sub pctObject_Click()
Dim FinishTime As Date ' the system time when user catches butterfly
Dim UserTime As Date ' amount of time it takes user to
' catch butterfly
Beep
pctObject.Picture = LoadPicture(App.Path & "\capturedbutterfly.bmp")
' load the picture of captured butterfly
tmrMoving.Enabled = False ' stop the butterfly
UserTime = Time - mStartTime ' calculating time it took user to
' catch butterfly
lblMessage.Caption = "Congratulations, you caught the butterfly in " & Format(UserTime, "h:m:s")
End Sub
Private Sub tmrMoving_Timer()
pctObject.Left = Int(Rnd * Form1.Width) + 1 ' moving the butterfly at random
End Sub