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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Click Event

Status
Not open for further replies.

akelly200

Programmer
Jan 15, 2001
8
0
0
US
Hi there
Many thanks in advance

I am trying to work out simple ratios. what i am doing is a simple test to work out if a mouse button is clicked for 30 seconds then a pause then for a further 30 seconds. firstly for the right hand and then for the left hand. the i would like to display the reults if possible.

If anyone could help i would appreciate it very much. and if possible any code that could be included would be muchly appreciated.

Once again many thanks for the help i revieve.
Andy
 
This isn't too hard. Here's what I would do.
Use the MouseDown event to detect the mouse button press. At that time initialize a timer to count the time elapsed, you can detect wich button was pressed by testing on the MouseDown event if Button = vbRightButton or vbLeftButton. Then on the MouseUp event get the value from the timer again, this way you'll know by how many time you had the right/left mouse button pressed.

This would be something like:

Public start, finish, elapsed

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

start = Timer

End Sub

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

finish = Timer
elapsed = finish - start
MsgBox (elapsed)

End Sub

If you try this code you will get the time you had the mouse button pressed, then you can check if it's the right/left button and other stuff you might need. But this is how you can get the elapsed time.

Hope this helps ( If so don't forget to give me a star :) )
If you need more help let me know
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top