Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleMake buttons that repeatedly modify a value when you hold them down
DescriptionThis example shows how to make buttons that repeatedly modify a value when you hold them down in Visual Basic 6. The buttons' MouseDown event handlers start a Timer. When the Timer fires, it modifies the value. The buttons' MouseUp event handlers disable the Timer.
Keywordsbutton, repeat button
CategoriesControls
 
The buttons' MouseDown event handlers start a Timer. When the Timer fires, it modifies the value. The buttons' MouseUp event handlers disable the Timer.
 
Private Sub cmdDown_MouseDown(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    m_Increment = -1
    tmrNumber.Enabled = True
End Sub

Private Sub cmdDown_MouseUp(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    tmrNumber.Enabled = False
End Sub

Private Sub cmdUp_MouseDown(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    m_Increment = 1
    tmrNumber.Enabled = True
End Sub

Private Sub cmdUp_MouseUp(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    tmrNumber.Enabled = False
End Sub

Private Sub tmrNumber_Timer()
Const MIN_NUMBER = -100
Const MAX_NUMBER = 100

    m_Number = m_Number + m_Increment
    If m_Number < MIN_NUMBER Then
        m_Number = MIN_NUMBER
    ElseIf m_Number > MAX_NUMBER Then
        m_Number = MAX_NUMBER
    End If

    txtNumber.Text = Format$(m_Number)
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated