delphi – Get CheckBox value from one form as boolean to another form

Question:

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

Answer:

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

var
  resInt: Integer;
begin
  resInt := Integer(CheckBox1.Checked) * -1;
end;
Scroll to Top