Pick up Checkbox value from a form as Boolean for another form

Asked

Viewed 646 times

3

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

2 answers

1

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

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

1

Try it this way

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

Remember to put in implementation uses to Unit of Form where is the TCheckBox1

implementation

{$R *.dfm}

uses USua_Unit_do_Form, ...;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.