Call Sub vs. fake a key press

  • Thread starter Thread starter Ricky W. Hunt
  • Start date Start date
Obviously it would be easier if there was just one subroutine
containing the code and that sub would be called from the If in the open
routine and from the stop routine.

Why not just do as you said in your post and put the code to stop playback
in a separate subroutine and call that from both places:

Private Sub StopPlayback()
If bPlaying Then
'Code to stop playback here
End If
End Sub

Private Sub OpenFile()
StopPlaying

'Other code here
End Sub

Private Sub StopButton_Click(...) Handles StopButton.Click
StopPlayback
End Sub

You can call the PerformClick method but if there are more than one handler
attached, they will all be executed. This is the most logical way, IMHO.

Regards,

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 
Chris Dunaway said:
Why not just do as you said in your post and put the code to stop playback
in a separate subroutine and call that from both places:

That was an option. I'm just learning VB though so I wanted to see what
methods were available and preferable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top