Checkbox in VB 6.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • godhulirbalaka
    New Member
    • Oct 2007
    • 26

    Checkbox in VB 6.0

    Hai, I have few checkbox in a form in vb 6.0. I want to set a command by which i can change all check box at a time
    Enable=True
    Enable=False
    .value=1,
    .value=0

    the code may something like for each checkbox....

    please give me the suggestion
  • jamesd0142
    Contributor
    • Sep 2007
    • 471

    #2
    checkboxname.ch ecked = false

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      Try this sample code

      [code=vb]
      Public Sub ResetControls(F rmCalled As Form)
      Dim i As Byte

      For i = 0 To FrmCalled.Contr ols.Count - 1
      If TypeOf FrmCalled.Contr ols(i) Is TextBox Then
      FrmCalled.Contr ols(i).Text = GEmptyStr
      FrmCalled.Contr ols(i).Tag = GEmptyStr
      End If
      If TypeOf FrmCalled.Contr ols(i) Is ComboBox Then
      FrmCalled.Contr ols(i).ListInde x = -1
      End If
      If TypeOf FrmCalled.Contr ols(i) Is Timer Then
      FrmCalled.Contr ols(i).Enabled = False
      End If
      If TypeOf FrmCalled.Contr ols(i) Is Image Then
      FrmCalled.Contr ols(i).Visible = False
      End If
      If TypeOf FrmCalled.Contr ols(i) Is ListView Then
      FrmCalled.Contr ols(i).ListItem s.Clear
      End If
      If TypeOf FrmCalled.Contr ols(i) Is CheckBox Then
      FrmCalled.Contr ols(i).Value = vbUnchecked
      End If
      Next i

      End Sub[/code]

      Comment

      • lotus18
        Contributor
        • Nov 2007
        • 865

        #4
        Hi godhulirbalaka

        Here's how to do it simplest way

        [code=vb]Dim ctrl as Control
        For Each ctrl In Me
        If TypeOf ctrl Is CheckBox Then
        If ctrl.Value = 1 Then
        ctrl.Value = 0
        Else
        ctrl.Value = 1
        End If
        End If
        Next
        [/code]

        Comment

        Working...