Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP Changes its mind over Checkbox
Message
From
04/07/2006 10:00:33
 
 
To
04/07/2006 09:52:47
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:
01133584
Views:
15
>>>>>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
>>>>
>>>>Hi Greg
>>>>
>>>>Yes I knew this (as I indicated in my spiel), and that one can set the default value (as I said I now have done), etc. My beef is that I put the checkbox on the form, wrote code to accommodate it, then it went and changed its data type from T/F to 1/0.
>>>>
>>>>Cheers
>>>>
>>>>Terry
>>>
>>>Terry,
>>>
>>>Change your test to if( !empty(...Value) ) instead of if( ...Value ).
>>
>>Thanks, Greg but what test are you talking about?
>
>
>The operator/operand type error of your first message
>
>Testing Empty() works on both numeric and logical data types

But I've still got to test for 1/0 or T/F, as below:
With Thisform 
  If this.Value <> .F.			&& so no need choose operator
      .txtOperator.enabled	    = .F.
      .cboOperators.enabled	    = .F.
      .lValidOp		    = .T.
  Else					&& Allow choose an operator
      .txtOperator.enabled	    = .T.
      .cboOperators.enabled	    = .T.
      If not EMPTY( .nOpCode)
          .lValidOp	    = .T.  	&& already got an operator from previous choice or default
      Else
	 .lValidOp	    = .F.
      EndIf 
  EndIf 
  .lmEnablePrint()
EndWith 
???????????????????/
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform