Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP Changes its mind over Checkbox
Message
From
04/07/2006 06:36:25
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01133547
Message ID:
01133549
Views:
16
>I'd always thought that checkboxes can have 3 values: 1 for checked, 0 for unchecked and (something else) for "Naaaaah, not sure - some of the list are and some aren't"). But I also knew, of course, that they can be T/F (never sure of the circumstances though when they're one or the other)
>
>So in testing the value in code I first tested for 1 or 0. VFP gave me an operator/operand type m-m error, so I went along with it, quite happily, and tested for T/F - all well and good.
>
>Since, I've made some changes to the form, but none to the checkbox logic. Now I go to test the form, click a checkbox and get an operator/operand type. In debug, the value of the checkbox is 0! So it's changed its mind!
>
>Give me a break!
>
>Has anyone found this problem and/or is there a definitive solution? I didn't set the initial value to the checkbox. Of course, in edit I find that it's 1. I've set it to .T. and don't get this error now. I presume it was .T. first of all - hence the first operator/operand type m-m error.
>
>I've had a similar problem with listboxes not being able to decide whether their value is char or num in the past, but I can't cite a definite example now. I've had to change code that was working, testing, say for num, to that testing for char. Very frustrating.

Terry,

Checkboxes can have 3 values

if (vartype(m.this.Value) == T_LOGICAL )
TRUE, FALSE or NULL

else >> Numeric
0, 1, or 2= null
endif

If, in your case it can only be true/false or 0/1, use empty(m.this.Value)

You can force its type to be logical by
(1) binding it to a logical Field, or
(2) if it does not have a controlsource, setting its default value to .T./.F. in the class
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform