by Mohammad Akram (4 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 29th June 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Special Butterfly, flying to the destination and back.
API Declarations
'Task - have three command buttons on the Form and a Special Butterfly to Fly and Back between the target.
Dim x As Integer
Dim y As Integer
Dim choice As String
'Task - have three command buttons on the Form and a Special Butterfly to Fly and Back between the target.
Dim x As Integer
Dim y As Integer
Dim choice As String
Private Sub cmdFly_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFly.Click
'moves Butterfly to the specified location
choice = "Fly"
'x = txtLeft.Text
'y = txtTop.Text
'If (x Mod 10 = 0) And (y Mod 10 = 0) Then
x = 280
y = 280
End Sub
Private Sub tmrButterfly1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrButterfly1.Tick
Dim picDart As Integer
Select Case choice
Case "Fly"
tmrButterfly1.Interval = 100
If (x > 20) And (y > 20) Then
x = x - 10
y = y - 10
bullseye.Location = New Point(x, y)
End If
Case "Back"
tmrButterfly1.Interval = 100
If (x < 280) And (y < 280) Then
x = x + 10
y = y + 10
bullseye.Location = New Point(x, y)
End If
End Select
End Sub
Private Sub cmdBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBack.Click
'Move Butterfly of the specified location
choice = "Back"
x = 20
y = 20
tmrButterfly1.Start()
Dim cmdBack = True
End Sub
Private Sub cmdQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdQuit.Click
'Quits Application
End
End Sub
Private Sub tmrDart_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrButterfly1.Tick
Dim Butterfly1 As Integer
Dim Location As Long
tmrButterfly1.Enabled = True
Select Case choice
Case "Fly"
tmrButterfly1.Interval = 100
If (x > 20) And (y > 20) Then
x = x - 10
y = y - 10
bullseye.Location = New Point(x, y)
End If
Case "Back"
tmrButterfly1.Interval = 100
If (x < 280) And (y < 280) Then
x = x + 10
y = y + 10
bullseye.Location = New Point(x, y)
End If
End Select
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
Label1.Text = True
End Sub
End Class