Results 1 to 26 of 26

Thread: [RESOLVED] check box to remove items from list?

Hybrid View

  1. #1

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    93

    Re: check box to remove items from list?

    it isnt going to work for what i want it for. that code removes the item from the list, and when the checkbox is unchecked, it does not come back. i need something to make the program randomize again when the label1.caption = the caption of the check box, only when the checkbox.value = true.
    Last edited by stevevb6; Jan 31st, 2007 at 01:11 PM.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    93

    Re: check box to remove items from list?

    how can i add an item to the list by clicking the check box,
    like this?
    VB Code:
    1. If chkboxuf1.Value = True Then
    2.       Dim lngIndex As Long
    3.     End If
    4.     For lngIndex = List1.ListCount - 1 To 0 Step -1
    5.         If List1.List(lngIndex) = "UF1" Then
    6.             List1.AddItem lngIndex
    7.                End If
    8.     Next

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: check box to remove items from list?

    Try something like this
    VB Code:
    1. Option Explict
    2. mstrSave As String
    3.  
    4.  
    5. If chkboxuf1.Value = True Then
    6.     Dim lngIndex As Long
    7.    
    8.     For lngIndex = List1.ListCount - 1 To 0 Step -1
    9.         If List1.List(lngIndex) = "AAA" Then
    10.             [HL="#FFFF80"]mstrSave = List1.List(lngIndex).List[/HL]
    11.             List1.RemoveItem lngIndex
    12.         End If
    13.     Next

    And then in the Click sub

    List1.AddItem mstrSave

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    93

    Re: check box to remove items from list?

    http://hx.pri.ee/dsrc/dice.php
    this is actually very close to the program i want to make. It is for a game that i play, some guy wanted it on the forum of the site and i figured it is a good way to get some vb6 skills.
    Last edited by stevevb6; Jan 31st, 2007 at 03:49 PM.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    93

    Re: check box to remove items from list?

    i got this one on my own. i used this code.
    VB Code:
    1. Dim s As Integer
    2.  
    3. For s = 0 To List1.ListCount - 1
    4. If List1.Selected(s) Then
    5. List3.AddItem List1.List(s)
    6. End If
    7. Next
    And then
    VB Code:
    1. Dim i As Integer
    2.    
    3.     Randomize
    4.     i = Rnd(List1.ListCount) * List3.ListCount
    5.     Label4.Caption = List3.List(i)
    Ironed out a few wrinckles, and all is well. Thanks for all your help!
    Last edited by stevevb6; Feb 2nd, 2007 at 08:36 AM.

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