Create a VB6 Command Button that fires repeatedly
Takeaway: There may be times when you want a VB6 Command Button to fire an event repeatedly, such as when you're performing an operation on multiple files. Learn how to create this kind of button in this VB tip.
A Visual Basic 6 Command Button normally fires one event each time it is clicked. However, you may want to create a button that fires an event repeatedly.
Follow these steps to create a button that fires an event repeatedly as long as it is down (and as long as the user has not released the mouse button):
- Add a Timer Control to the form and set its Interval property to the desired interval between repeated events.
- Put the code to be executed repeatedly in the Timer's Timer Event procedure.
- Set the Timer's Enabled property to True in the Command Button's MouseDown event procedure.
- Set the Timer's Enabled property to False in the Command Button's MouseUp event procedure.
This kind of repeating Command Button can be useful in a variety of programming situations, such as performing an operation on multiple files.
Miss a tip?
Check out the Visual Basic archive, and catch up on the most recent editions of Peter Aitken's column.
Advance your scripting skills to the next level with TechRepublic's free Visual Basic newsletter, delivered each Friday. Automatically sign up today!
Print/View all Posts Comments on this article
SponsoredWhite Papers, Webcasts, and Downloads
- Sharepoint Customization Best Practices Global Knowledge
- TCP/IP Troubleshooting Global Knowledge
- ITIL Version 3.0 -- What It Means to You Global Knowledge
- Using the Six Laws of Persuasion in Negotiations Global Knowledge
- SQL Server 2008: What to Expect Global Knowledge
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET





