|
-
Oct 3rd, 2000, 11:02 AM
#1
Thread Starter
Frenzied Member
when i press backspace, the code fires up
but how come when i press DELETE nothing happens?
Code:
Private Sub lstRange_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyBack Or KeyAscii = vbKeyDelete Then
MsgBox "hi"
lstRange.RemoveItem lstRange.ListIndex
End If
End Sub
-
Oct 3rd, 2000, 11:11 AM
#2
Lively Member
You need to do this
Code:
Private Sub lstRange_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDelete Then
MsgBox "hi"
End If
End Sub
Private Sub lstRange_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyBack Then
MsgBox "hi"
End If
End Sub
-
Oct 3rd, 2000, 11:15 AM
#3
Thread Starter
Frenzied Member
just curios
isn't vbKeyDelete fired on keypress? seems not to be
do you know why thou?
since vbKeyBack is fired...
thanks for the help anyways
i will test what ya just gave me
-
Oct 3rd, 2000, 11:41 AM
#4
Lively Member
Well, actually, you can do this, too.
Code:
Private Sub lstRange_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDelete Or KeyCode = vbKeyBack Then
MsgBox "hi"
End If
End Sub
I guess the reason why it doesn't work in the Keypress sub because the VB doesn't count the delete key as an ascii key like alphabets or numeric letters.
-
Oct 3rd, 2000, 02:36 PM
#5
KeyAscii can be used as well.
Code:
Private Sub lstRange_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 8 Or 46
MsgBox KeyAscii
End Select
End Sub
Or KeyCode can be used:
Code:
Private Sub lstRange_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyBack Or vbKeyDelete
MsgBox KeyCode
End Select
End Sub
-
Oct 3rd, 2000, 02:54 PM
#6
Lively Member
Hi Matthew,
Are you sure that your code in the KeyPress sub work? I tried it and it didn't work as I expected because it is the same thing as Kovan code. Moreover, constant keycode, such as vbKeyDelete or vbKeyReturn, etc., give you an integer value. Therefore, I don't think it will make different between pure numeric type like you did and enum type, such as vbKeyBack.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|