1

I have a VBA form in Excel with "Next" and "Previous" buttons that update an Image control's picture source.

I would like to be able to click these buttons very quickly in succession in order to loop through the images. However, when I click twice in short succession (double click) I only get one response.

I suspect that this is the case because there is a double click event on the button that gets triggered instead of the click event when two clicks are very close to each other.

My goal would be to disable the double-click event altogether, allowing me to click the button as quickly as I want. Is there a way to do that?

2
  • have you tried to put in your DoubleClick event set Cancel = True? Commented Nov 8, 2017 at 20:49
  • @David G. Won't work; it's MouseUp... Commented Nov 8, 2017 at 20:52

3 Answers 3

2

Intercept the MouseUp event instead.

Sign up to request clarification or add additional context in comments.

1 Comment

Good idea, but doesn't work. Apparently the MouseDown is only called once per double-click.
0

Regular command buttons might not be the best control; what you're doing sounds like it calls more for a spin button (the one with the next/back control).

If that doesn't cut it, the stupidly simple solution would be to have the double click even simply call the click event twice.

1 Comment

Good point with the spin button; I'll look into that - and yes, calling the click event from double click works fine.
0

I actually figured out a pretty easy workaround for this:

In the DoubleClick event, I can simply call the Click event like so:

Private Sub NextBtn_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    NextBtn_Click
End Sub

I am now able to click the button as fast as I want and after each click the same code is executed.

3 Comments

Invoking event handlers "manually" like this is a very strong sign that you're doing something wrong. Event handlers aren't normal procedures, they handle events.
True; ideally I would call a function like "GoToNextImage" from both event handlers. (I was just too lazy for my purposes to create a separate function)
Yet handling the proper event makes a much more robust and elegant solution doesn't it :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.