Get CheckBox value from one form as boolean for another form

3

I have checkbox in a form and I want to receive the value of it in another form as boolean , for example: CheckBox1.Checked = true want to receive as value 1 , and CheckBox1.Checked = false want to receive as value 0

    
asked by anonymous 26.10.2017 / 18:47

2 answers

1

Use the Integer() function to convert a Boolean to Integer , then multiply by -1 because the return of this function when CheckBox1.Checked is True is -1 and not 1 :

var
  resInt: Integer;
begin
  resInt := Integer(CheckBox1.Checked) * -1;
end;
    
26.10.2017 / 18:52
1

Try this out

if SeuForm.CheckBox1.Checked = False then
  SuaVar := 0
else 
  SuaVar := 1;

implementation

{$R *.dfm}

uses USua_Unit_do_Form, ...;
    
11.11.2017 / 13:11