check box visual basic 6.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anirban
    New Member
    • Sep 2006
    • 17

    check box visual basic 6.0

    I used four check box
    named chk1,chk2,chk3, chk4 initialy all unchecked
    when I check any one the caption is viewed in the text box where
    I want to view it

    if I uncheck the check box in following order it working fine
    chk4,chk3,chk2, chk1

    but when I uncheck the check box not in a particular way it does not work
    properly
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by anirban
    I used four check box ... but when I uncheck the check box not in a particular way it does not work properly
    Please post your code, or at least give us a more detailed description of what you are doing with their captions.

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      It looks like your code is written only half the way
      try to implemt the same for all the controls

      or

      user control array

      Comment

      • anirban
        New Member
        • Sep 2006
        • 17

        #4
        Originally posted by Killer42
        Please post your code, or at least give us a more detailed description of what you are doing with their captions.
        part of the code
        there are three another three not send to you

        Code:
        Private Sub chk4_Click()
        If chk4.Value = 1 Then
        txt1.Text = Trim(txt1.Text) + " " + Trim(chk4.Caption)
        End If
        If chk4.Value = 0 Then
        txt1.Text = " "
        If chk1.Value = 1 Then
        txt1.Text = Trim(txt1.Text) + Trim(chk1.Caption)
        End If
        If chk2.Value = 1 Then
        txt1.Text = Trim(txt1.Text) + Trim(chk2.Caption)
        End If
        If chk3.Value = 1 Then
        txt1.Text = Trim(txt1.Text) + Trim(chk3.Caption)
        End If
        End If
        end sub
        Last edited by Killer42; Feb 18 '07, 08:51 PM. Reason: Please use CODE tags

        Comment

        • sukeshchand
          New Member
          • Jan 2007
          • 88

          #5
          Check this code

          Code:
          Private Sub chk4_Click()
              chkBoxClick
          End Sub
          Private Sub chk3_Click()
              chkBoxClick
          End Sub
          Private Sub chk2_Click()
              chkBoxClick
          End Sub
          Private Sub chk1_Click()
              chkBoxClick
          End Sub
          
          Private Function chkBoxClick()
          txt1.Text = ""
          If chk1.Value = 1 Then
              txt1.Text = txt1.Text & " " & chk1.Caption
          End If
          If chk2.Value = 1 Then
              txt1.Text = txt1.Text & " " & chk2.Caption
          End If
          If chk3.Value = 1 Then
              txt1.Text = txt1.Text & " " & chk3.Caption
          End If
          If chk4.Value = 1 Then
              txt1.Text = txt1.Text & " " & chk4.Caption
          End If
          End Function

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Good advice there, sukeshchand.

            And keep in mind, anirban, that a control array will make this sort of thing much simpler to work with. The main reason being, you would then be able to use a loop to process all of them with less code.

            Comment

            • anirban
              New Member
              • Sep 2006
              • 17

              #7
              thanks the problem is solved by your suggestion

              Comment

              Working...