Excel VBA Timer Keeps Stopping -


I currently have a macro when I click anywhere on a userform, a picture box is moved to the left. I have added a timer on it so that it will always run after clicking the first form. The problem is that the picture box goes to the left, but only once. After this, nothing happens to my code so far:

  Private sub UserForm_MouseUp (Volt button as integer, in the form of integer, single as bi val x, by CallUsing single player) Call PlayerMoving and All Folk All PlayerMOISSING () Player1.Left = Player1.Left + 5 Call StartTemer and Sub subtitleer () application. Onetime now + Time Vila ("00:00:01"), "PlayerMoving" And sub   

Like I mentioned earlier, the first step Prahlad, nothing happens. I do not know why I also tried to do this:

  While doing a public sub-player (SOME_STATEMENT_HERE Player1.Left = Player1.Left + 5 call startup loop   

End all

Great question! The answer for this is with the application.onetime function. It is designed to call processes that are not in the regular module , not the class objects such as Forms. In other words, the onetime function can not be found for your PlayerMoving because it is in the category of your form rather than the regular module.

To correct this, you can simply add the following cover function in a regular VBA module:

  Public Sub MoveMyPlayer () UserForm1.PlayerMoving End Sub   

Then reside in your current module Call to schedule the MoveMyPlayer function

  Public sub start time () Application. Onetime Now + Time Vila ("00:00:01"), "MovablePlayer" and Sub   

Also keep in mind that while closing your timer, your code will stop There should be a way of field. You probably want to add another function to your form, and when you are ready to stop running the image, call it:

  Public Sub-cancel Timer () application. Now time, "Movemplier", wrong last sub   

Hope that helps!

Adam

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -