Results 1 to 2 of 2

Thread: simple checkbox questions

  1. #1

    Thread Starter
    Fanatic Member Navarone's Avatar
    Join Date
    Jun 2003
    Location
    Akron, Ohio USA
    Posts
    740

    simple checkbox questions

    I have two check boxes; If I click on the first the box is checked, if I click on the second, I want the first box to uncheck and the second to be checked. I thought this code would do the job, but it's working like I want. What do I need to do here?

    VB Code:
    1. 'for check box's 1 or 2 only one can be checked
    2.    If Checkbox(1).Value = 1 Then
    3.         Checkbox(2).Value = 0
    4.    End If
    5.  
    6.    If Checkbox(2).Value = 1 Then
    7.          Checkbox(1).Value = 0
    8.    End If
    He who never made a mistake never made a discovery?

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: simple checkbox questions

    You should really use Option Buttons. They do that withouth the code, but still:

    VB Code:
    1. Private Sub Checkbox_Click(Index As Integer)
    2.     Select Case (Index)
    3.         Case 0:
    4.             If Checkbox(0).Value = vbChecked Then Checkbox(1).Value = vbUnchecked
    5.         Case 1:
    6.             If Checkbox(1).Value = vbChecked Then Checkbox(0).Value = vbUnchecked
    7.     End Select
    8. End Sub

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