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 a CommandButton process clicks and spaces but not carriage returns
KeywordsCommandButton, button, carriage return
CategoriesControls
 
Fire the button in the MouseUp and KeyUp event handlers, not the Click event handler.
 
Private Sub Command1_KeyUp(KeyCode As Integer, Shift As _
    Integer)
    If KeyCode = vbKeySpace Then
        Beep    ' Do something
    End If
End Sub

Private Sub Command1_MouseUp(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    If X >= 0 And X <= Command1.Width And _
       Y >= 0 And Y <= Command1.Height _
    Then
        Beep    ' Do something
    End If
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated