Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Repeat procedure after i seconds

Status
Not open for further replies.

sfenx

Programmer
Feb 23, 2001
81
BE
This must be an easy one, but I'm trying for a long time already, so I'll ask you guys. I'm using an updown-control. When I click the Up or Down button, a procedure is started. What I would like to do is repeat this procedure after a certain time when the user is still clicking the button.
This is what I've got so far...

Code:
Private Sub updPlanning_DownClick()
  Call Procedure1
End Sub

Private Sub updPlanning_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  Dim sStart As Single, sStop As Single
  DoEvents
  Call Procedure1
  sStart = Timer
  sStop = Timer + 0.25
  Do Until sStart >= sStop
    sStart = Timer
  Loop
End Sub[\code]

Sfenx 8-)
 
Hi, you can use the mouseUp/MouseDown events to do that.

On the mouseDown event make a variable = true (you decide if it needs to be public or not), like

Private Sub cmdDown_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Mousepressed=True

End sub

On the mouse up event

Private Sub cmdDown_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Mousepressed=False

End sub

Then to check if the button is still pressed just check the value of the Mousepressed variable.
After x seconds test if Mousepressed=true if so repeat the procedure, if not don't.

Hope this helps.
 
You should use the Timer Object. It has an Interval property for the interval you want to set and also an Timer event, in which you should put your call to the repeating procedure.

Hope this helps,s-) Blessed is he who in the name of justice and good will, shepards the week through the valley of darknees...
 
Thanks, daimaou. I still have the problem that the UpProcedure is executed when the button is released. After that, the MousePressed variable is false. Something is definitly missing. What am I doing wrong ?

Code:
Private Sub updPlanning_DownClick()
  Call ProcedureUp
  DoEvents
  sStart = Timer
  sStop = Timer + 0.15
  Do Until sStart >= sStop
    sStart = Timer
  Loop
  Do Until MousePressed = False
    Call ProcedureUp
  Loop
End Sub

Private Sub updPlanning_MouseDown(Button As Int...)
  MousePressed = True
End Sub

Private Sub updPlanning_MouseUp(Button As Int...)
  MousePressed = False
End Sub[\code]
8-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top