Results 1 to 6 of 6

Thread: [RESOLVED] Help :No keyboard only mouse

  1. #1

    Thread Starter
    Hyperactive Member shirishdawane's Avatar
    Join Date
    Dec 2004
    Location
    Mumbai,India
    Posts
    363

    Resolved [RESOLVED] Help :No keyboard only mouse

    I am using listbox with checkboxes into it & I want to opearte that listbox only with mouse not with keyboard then is that possible to do that? if yesthen please give any instant solution......Thanx.
    Last edited by shirishdawane; Feb 25th, 2006 at 11:47 AM.
    On Error GoTo http://www.vbforums.com

    Note :
    1) Please use [vbcode]your code goes in here [/vbcode] tags when posting VB code.
    2) Please mark thread as Resolved using the Thread Tools menu, if you got solution.

  2. #2
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: No keyboard only mouse

    Quote Originally Posted by shirishdawane
    I am using listbox with checkboxes into it & I want to opearte that listbox only with mouse not with keyboard then is that possible to do that? if yesthen please give any instant solution......Thanx.
    You can just cancel all of the KeyPresses going to it.
    VB Code:
    1. Private Sub List1_KeyPress(KeyAscii As Integer)
    2.  
    3.     KeyAscii = 0
    4.  
    5. End Sub

  3. #3

    Thread Starter
    Hyperactive Member shirishdawane's Avatar
    Join Date
    Dec 2004
    Location
    Mumbai,India
    Posts
    363

    Re: No keyboard only mouse

    Quote Originally Posted by Comintern
    You can just cancel all of the KeyPresses going to it.
    VB Code:
    1. Private Sub List1_KeyPress(KeyAscii As Integer)
    2.  
    3.     KeyAscii = 0
    4.  
    5. End Sub
    Actually I am doing in this way :
    VB Code:
    1. Private Sub lstregno_ItemCheck(Item As Integer)
    2.      
    3.     For i = 0 To lstregno.ListCount - 1
    4.         If lstregno.Selected(i) = True Then
    5.             lstregno.Selected(i) = False
    6.         End If
    7.     Next
    8.  
    9.     lstregno.Selected(lstregno.ListIndex) = True
    10. End Sub

    but when I try to select/ disselect checkboxes with "Spacebar" button then it goes into infinite loob of FOR loop & shows error " Out of Stack". o is there any way to check that space bar has bben pressed ?
    On Error GoTo http://www.vbforums.com

    Note :
    1) Please use [vbcode]your code goes in here [/vbcode] tags when posting VB code.
    2) Please mark thread as Resolved using the Thread Tools menu, if you got solution.

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: No keyboard only mouse

    Quote Originally Posted by shirishdawane
    is there any way to check that space bar has bben pressed ?
    VB Code:
    1. Private Sub List1_KeyPress(KeyAscii As Integer)
    2.  
    3.     if KeyAscii <> 32 then KeyAscii = 0
    4.  
    5. End Sub

  5. #5
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: Help :No keyboard only mouse

    Check for spacebar presses by testing the KeyAscii against 32. If you are somehow generating an infinite loop by recursing the function, add a static indicator to check if the code is in progress:

    VB Code:
    1. Private Sub List1_KeyPress(KeyAscii As Integer)
    2.      
    3.     Dim iItem As Integer
    4.     Static bInProg As Boolean
    5.    
    6.     If bInProg = False Then
    7.         If KeyAscii = 32 Then       'Check for space
    8.             For iItem = 0 To List1.ListCount - 1
    9.                 If List1.Selected(iItem) = True Then
    10.                     List1.Selected(iItem) = False
    11.                 End If
    12.             Next
    13.             bInProg = True
    14.                 List1.Selected(List1.ListIndex) = True
    15.             bInProg = False
    16.         Else
    17.             KeyAscii = 0
    18.         End If
    19.     End If
    20. End Sub

  6. #6

    Thread Starter
    Hyperactive Member shirishdawane's Avatar
    Join Date
    Dec 2004
    Location
    Mumbai,India
    Posts
    363

    Re: Help :No keyboard only mouse

    Thanx guys it works.
    Last edited by shirishdawane; Feb 27th, 2006 at 03:06 AM.
    On Error GoTo http://www.vbforums.com

    Note :
    1) Please use [vbcode]your code goes in here [/vbcode] tags when posting VB code.
    2) Please mark thread as Resolved using the Thread Tools menu, if you got solution.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width