Forum Discussion

Morgan's avatar
Morgan
Frequent Contributor
11 years ago
Solved

.value to set a checkbox

I want to set a checkbox to checked using the .value property (which returns checked or unchecked).  The property says it can also SET the checkbox but I'm having trouble doing that for whatever reason.  I'm sure it's simple.... help?  (using VB)



Morgan
  • Try using



       chkobj.Value=0 or chkobj.Value=1

      

       0- unchecked

       1-checked



    instead u can also use



        chkobj.Clickbutton(cbChecked) or chkobj.Clickbutton(cbUnchecked)

4 Replies

  • murugans1011's avatar
    murugans1011
    Regular Contributor
    Try using



       chkobj.Value=0 or chkobj.Value=1

      

       0- unchecked

       1-checked



    instead u can also use



        chkobj.Clickbutton(cbChecked) or chkobj.Clickbutton(cbUnchecked)
  • Morgan's avatar
    Morgan
    Frequent Contributor
    Thank you!  I used the first approach and it worked perfectly!
  • sbkeenan's avatar
    sbkeenan
    Frequent Contributor
    Hi Morgan



    You may also find that your checkbox control has a native Set_Checked method, that accepts either a true or false parameter.  I find that this tends to make the code slightly easier to read.  For example, if your control is referenced by the variable chkCtrl, then you could use something like:





    chkCtrl.Set_Checked(true)      'this will check the checkbox control.



    chkCtrl.Set_Checked(false)    'this will un-check the checkbox control.





    Regards

    Stephen.
  • Morgan's avatar
    Morgan
    Frequent Contributor
    Valid point!  I'll look into that.  Thank you!