Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Delete key ListBox

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,61605
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Delete key ListBox
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Delete key ListBox - 6/18/2008 9:51:26 PM   
  SilentBob


Posts: 38
Score: 0
Joined: 3/27/2007
Status: offline
Hi,

I have the following sub that deletes a selected item from a listbox in a hta.
When hitting Backspace it works, but not with Delete.

Any idea why the Delete key doesn't work?

(Lists is a form tag, Samplecodes is the listbox (select tag) inside the form)

Sub Lists_onKeyPress
 Dim objOption
 If window.event.keycode = 127  or window.event.keycode = 8 Then
  For Each objOption in Lists.Samplecodes.Options
   If objOption.Selected Then
    objOption.removenode
   End If
  Next
 End If
 
End Sub

_____________________________

If you're looking for the truth, STOP lying.
 
 
Post #: 1
 
 RE: Delete key ListBox - 6/18/2008 11:45:46 PM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
Do you get any return if you do something like this?

If window.event.keycode = 127  then
   Wscript.echo "127"
ElseIf window.event.keycode = 8 Then
   Wscript.Echo "8"
End if

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to SilentBob)
 
 
Post #: 2
 
 RE: Delete key ListBox - 6/18/2008 11:54:41 PM   
  ehvbs

 

Posts: 2201
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi SilentBob,

look at

  http://safari.ibmpressbooks.com/0596004672/jvdhtmlckbk-APP-A
  http://safari.ibmpressbooks.com/0596004672/jvdhtmlckbk-APP-A#X2ludGVybmFsX1RvYz94bWxpZD0wNTk2MDA0NjcyL2p2ZGh0bWxja2JrLUFQUC1C

and use the onKeyUp event (checking for Del == 46 and BS == 8).

Good luck!

ehvbs

(in reply to SilentBob)
 
 
Post #: 3
 
 RE: Delete key ListBox - 6/26/2008 5:46:02 AM   
  SilentBob


Posts: 38
Score: 0
Joined: 3/27/2007
Status: offline
Thx ehvbs,

onKeyUp (or onKeyDown) worked with window.event.keycode = 46
I don't  get why it's 46 (ascii for .  which is del on the numpad).
When using onKeyUp it acts as a del key (not . on numpad), when using onKeyPress it acts like . (dot)

_____________________________

If you're looking for the truth, STOP lying.

(in reply to ehvbs)
 
 
Post #: 4
 
 RE: Delete key ListBox - 6/26/2008 5:55:30 AM   
  ehvbs

 

Posts: 2201
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi SilentBob,

you are welcome. To understand (the difference between) key and character codes (and
which event delivers what kind of code) just read the intro in the second link I gave you (again).

Good luck!

ehvbs

(in reply to SilentBob)
 
 
Post #: 5
 
 RE: Delete key ListBox - 6/27/2008 4:09:32 AM   
  SilentBob


Posts: 38
Score: 0
Joined: 3/27/2007
Status: offline
quote:

ORIGINAL: ehvbs
...
(again).
...



shame on me

just read it, oh so easy

_____________________________

If you're looking for the truth, STOP lying.

(in reply to ehvbs)
 
 
Post #: 6
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Delete key ListBox Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts