Results 1 to 6 of 6

Thread: CheckBox select/deselect help..

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    Hi,

    What I'm trying to do is to write some code which will treat an array
    of CheckBoxes just like they were option boxes so that only 1 CheckBox
    can be selected at a time. But the catch is that the user should also
    be able to not have any selections which is why I'm using the CheckBox.

    For example, I have a control array of 4 CheckBoxes named chkShipPay.

    If index 3 is currently selected and the user clicks on index 2, 3 should be unchecked
    and 2 should be checked. If the user then clicks 2 again, it should be unchecked.

    I tried various code in the click event but it allways seems to go in an infinite
    loop and terminates..

    Any help or ideas would be greatly appreciated..

    Dan

  2. #2
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    Try this:
    Not Tested!!!

    Code:
    Private Sub chkShipPay_Click (Index As Integer)
    Dim chk as CheckBox
    
    For Each chk In chkShipPay
         chk.Value = 0
    Next
    
    chkShipPay(Index).Value = 1
    
    End Sub
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    Thanks, but doesn't work either.. It also goes into an infinite loop. Also, even if your code were to work, it wouldn't allow for "deselecting" a checkbox.. There would allways be 1 checked.. But remember, I want to also allow the user the option of not making any selections or deselecting an already selected option..

  4. #4
    Guest
    Why not have options buttons. If you want the choice of having no items selected, make a "None" option.

  5. #5
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    Sorry, I wasn't thinking, go with Megatron
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    Okay, Megatron's suggestion will work.. I thought about that but just wanted to see if I could make it work but I guess it won't be simple..

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