The code below (look at the part that deals with left and right arrows) isse beeps when I press left or right arrows How can I avoid that (beside shutting down the sound )
This is the relevant code:
[code]If Key = Chr(28) Then // Left Key: move to top
If Me.ListIndex > 0 Then
// NO BEEP PLEASE: this is not an error !
Me.ListIndex = Me.ListIndex - 1
// * far below
End If
ElseIf Key = Chr(29) Then // Right Key: move to bottom
If Me.ListIndex < (Me.ListCount - 1) Then
// NO BEEP PLEASE: this is not an error !
Me.ListIndex = Me.ListIndex + 1
// * far below
End If
End If
[/code]
Extracted from the ListBox KeyDown Event
:
[code]Function KeyDown(Key As String) As Boolean
//
// Allows to Edit the selected Row with Enter or Return pressed keys
// and change the Row selection if the left key (top) or the right key (bottom) are pressed.
//
Dim SelRow As Integer // To hold the selected Row #
// Do nothing if no Row is selected
If Me.SelCount < 1 Then
Return False
End If
// Get the selected Row #
SelRow = LB.ListIndex
// Change the Selected Row to the previous (Left Arrow) or next (Right Arrow) Row
If Key = Chr(28) Then // Left Key: move to top
If Me.ListIndex > 0 Then
Me.ListIndex = Me.ListIndex - 1
End If
ElseIf Key = Chr(29) Then // Right Key: move to bottom
If Me.ListIndex < (Me.ListCount - 1) Then
Me.ListIndex = Me.ListIndex + 1
End If
End If
If (Key = Chr(4) Or Key = Chr(13)) Then
// Edit the selected Row
Me.EditCell(SelRow, 1)
// I handled these characters (both: Enter and Return)
Return True
End If
End Function[/code]
TIA.
- I can add an Else clause here and jump to the top (if I the current is the last Row) or bottom (if the current Row is the first Row) of the ListBox.