Results 1 to 3 of 3

Thread: listbox error...[RESOLVED]

  1. #1

    Thread Starter
    Lively Member smartrajesh's Avatar
    Join Date
    Feb 2005
    Posts
    94

    Question listbox error...[RESOLVED]

    hai,
    i had a code in command button click event given bellow:

    private sub command_click event()
    For i = 0 To Lst_Itm_Cat.ListCount - 1
    If Lst_Itm_Cat.Selected(i) = True Then Lst_Itm_Cat.Selected(i) = False
    Next
    end sub

    as well as i had a code in lst_itm_cat (listbox control) click event. my problem is whenever i call the command click event the lst_itm_cat (listbox control)click event was trigred. i don't know why? plz help me...how to avoid this...

  2. #2
    Lively Member sishe's Avatar
    Join Date
    Aug 2004
    Location
    Izmit/Turkey
    Posts
    115

    Re: listbox error...[RESOLVED]

    As soosn as you select or deselect items in listbox, it will generate click event.

    So try to declare a global boolean variable for detecting if the command button is pressed.

    Like this;

    VB Code:
    1. Dim bButtonClicked As Boolean
    2.  
    3. Private Sub Command1_Click()
    4.  
    5.     bButtonClicked = True
    6.     For i = 0 To lst_itm_cat.ListCount - 1
    7.         If lst_itm_cat.Selected(i) = True Then lst_itm_cat.Selected(i) = False
    8.     Next
    9.     bButtonClicked = False
    10.  
    11. End Sub
    12.  
    13. Private Sub Form_Load()
    14.  
    15.     bButtonClicked = False
    16.  
    17. End Sub
    18.  
    19. Private Sub lst_itm_cat_Click()
    20.  
    21.     If bButtonClicked Then Exit Sub
    22.  
    23.     'Your code for ListBox Click Event
    24.  
    25. End Sub
    System Halted..
    -----------------------------------------
    Sishe

  3. #3

    Thread Starter
    Lively Member smartrajesh's Avatar
    Join Date
    Feb 2005
    Posts
    94

    Smile Re: listbox error...[SOLVED]

    thanks sishe.....u r from .......i am new to vb. so plz tell me tricks and tips abt vb 6.0
    bye..
    regards
    RajeshKumar.M

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