Help_me_Mannn
08-30-2009, 07:00 AM
Well i have an exam coming up and one of the past papers has this as a question:
Comment on the documentation within the above code. Can you determine the purpose of the RunAway function.
A copy of the code:
Public Sub RunAway (X as Single, Y as Single, Distance As Integer)
Dim NewLeft As Single
Dim NewTop As Single
‘Me being the current form and cmdMove a button on this form
If Y > Me.cmdMove.Top – 100 And Y<Me.cmdMove.Top + Distance + Me.cmdMove.Height Then
‘Horizontally in line
Me.cmdMove.Top = (Me.Height – Me.cmdMove.Height – 400) * Rnd
If X > Me.cmdMove.Left – 100 And X < Me.cmdMove.Left + Distance +Me.cmdMove.Width Then
‘also vertically in line
Me.cmdMove.Left = (Me.Width – Me.cmdMove.Width) * Rnd
End If
End if
EndSub
Can someone please comment each line of the code and tell me what it means. zzz Exam is in a day thanks :D
Comment on the documentation within the above code. Can you determine the purpose of the RunAway function.
A copy of the code:
Public Sub RunAway (X as Single, Y as Single, Distance As Integer)
Dim NewLeft As Single
Dim NewTop As Single
‘Me being the current form and cmdMove a button on this form
If Y > Me.cmdMove.Top – 100 And Y<Me.cmdMove.Top + Distance + Me.cmdMove.Height Then
‘Horizontally in line
Me.cmdMove.Top = (Me.Height – Me.cmdMove.Height – 400) * Rnd
If X > Me.cmdMove.Left – 100 And X < Me.cmdMove.Left + Distance +Me.cmdMove.Width Then
‘also vertically in line
Me.cmdMove.Left = (Me.Width – Me.cmdMove.Width) * Rnd
End If
End if
EndSub
Can someone please comment each line of the code and tell me what it means. zzz Exam is in a day thanks :D