Checkbox.setValue does not work

The commands below are in the ‘Main’ start-up routine.
They cause the Label to say “undefined” instead of “true”, and they cause the message box to say “CheckBox value is undefined” instead of “CheckBox value is true”.
*** How can I set, and then read the value of the checkbox correctly?
(I have tried with checkboxes from both Bootstrap 4 and jqWidgets).
Thanks.

CheckBox22.setValue(1,True)
Label2.text = CheckBox22.getValue(1)
NSB.MsgBox "CheckBox value is " & CheckBox22.getValue(1)

Your CheckBox22 not Checkbox22 by any chance? Trips me up regularly

Hi,

It has tripped me up many times also.

No, I have tried the current example with both spellings.

Ray

as I am not with my pc now, and what I have worked with is radio button, as the theory behind is similar, this only serve as a rough guide

A =0

Function radioButton1_onchange() 
A = 47
'my radiobutton is @the last index. 
B =a +2
' my first value is 2,you have to set your own value, bear in mind the 1st index is 0
A = radiobutton. value
If (a==undefined) or (a==null) then
If (a==undefined) or (a==null) 
Then
'err
A = 47
B =49
Radiobutton1.value=a
Else
' ok
B=47
End if
End if```

Tip: If you’re pasting code, html or config files, surround it by triple back ticks (```) and it will be fomatted properly.

I created a little app and pasted your code in. It seemed to work ok. Could the actual problem lie elsewhere in your code?

Screen Shot 2020-10-05 at 10.39.21 AM

May be there is no value if u doesn’t check the check box and press a button and gets checkbox value.

Thanks. Replies appreciated.
I used a single-value check box; it was a Bootstap4 check box and so its starting location was zero. I incorrectly thought that it was a jqWidgets check box, and their starting location is not zero but one. The result was that if one sets the value(1) in a Bootstrap4 check box, it will be recorded as “undefined” because I had, in fact, no location (1).